[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
kbr at google.com
kbr at google.com
Wed Dec 22 11:42:35 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit f46833867e58ef64506645ae5336bb0feaf41121
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Aug 4 17:48:02 2010 +0000
2010-08-02 Kenneth Russell <kbr at google.com>
Reviewed by Dimitri Glazkov.
Port Chromium's accelerated compositing to Mac OS X
https://bugs.webkit.org/show_bug.cgi?id=43398
* public/WebGLES2Context.h:
- Added resizeOnscreenContent, needed on Mac OS X to report
window size changes.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::resize):
- Send resize notification to the WebGLES2Context.
(WebKit::WebViewImpl::updateRootLayerContents):
- Ported to Core Graphics.
(WebKit::WebViewImpl::gles2Context):
- Added initial size notification upon context creation.
2010-08-02 Kenneth Russell <kbr at google.com>
Reviewed by Dimitri Glazkov.
Port Chromium's accelerated compositing to Mac OS X
https://bugs.webkit.org/show_bug.cgi?id=43398
No new tests. Tested manually with CSS 3D and WebGL tests.
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::clearBorderColor):
(WebCore::clearLayerBackgroundColor):
- Fixed compilation problems with gcc.
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerChromium::updateTextureContents):
- Added Core Graphics port.
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::LayerChromium):
- Fixed compilation problems with gcc related to initialization
order of members.
(WebCore::LayerChromium::updateTextureContents):
(WebCore::LayerChromium::updateTextureRect):
- Ported to Core Graphics, adjusting for lower-left coordinate
system origin.
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::LayerRendererChromium):
- Fixed compilation problems with gcc related to initialization
order of members.
(WebCore::LayerRendererChromium::setRootLayerCanvasSize):
- Ported to Core Graphics.
(WebCore::LayerRendererChromium::drawLayers):
- Added more debug-only error calls during drawing phase.
Adjusted scrolling and incremental updating code for Core
Graphics' lower-left coordinate system origin.
(WebCore::LayerRendererChromium::initializeSharedGLObjects):
- Removed color channel swizzling in Core Graphics port. Fixed
preexisting bug in initialization check of m_rootLayerTextureId.
* platform/graphics/chromium/LayerRendererChromium.h:
- Added needed data members for Core Graphics port.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 16a7bf5..d5a54f3 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,43 @@
+2010-08-02 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Dimitri Glazkov.
+
+ Port Chromium's accelerated compositing to Mac OS X
+ https://bugs.webkit.org/show_bug.cgi?id=43398
+
+ No new tests. Tested manually with CSS 3D and WebGL tests.
+
+ * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+ (WebCore::clearBorderColor):
+ (WebCore::clearLayerBackgroundColor):
+ - Fixed compilation problems with gcc.
+ * platform/graphics/chromium/ImageLayerChromium.cpp:
+ (WebCore::ImageLayerChromium::updateTextureContents):
+ - Added Core Graphics port.
+ * platform/graphics/chromium/LayerChromium.cpp:
+ (WebCore::LayerChromium::LayerChromium):
+ - Fixed compilation problems with gcc related to initialization
+ order of members.
+ (WebCore::LayerChromium::updateTextureContents):
+ (WebCore::LayerChromium::updateTextureRect):
+ - Ported to Core Graphics, adjusting for lower-left coordinate
+ system origin.
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::LayerRendererChromium):
+ - Fixed compilation problems with gcc related to initialization
+ order of members.
+ (WebCore::LayerRendererChromium::setRootLayerCanvasSize):
+ - Ported to Core Graphics.
+ (WebCore::LayerRendererChromium::drawLayers):
+ - Added more debug-only error calls during drawing phase.
+ Adjusted scrolling and incremental updating code for Core
+ Graphics' lower-left coordinate system origin.
+ (WebCore::LayerRendererChromium::initializeSharedGLObjects):
+ - Removed color channel swizzling in Core Graphics port. Fixed
+ preexisting bug in initialization check of m_rootLayerTextureId.
+ * platform/graphics/chromium/LayerRendererChromium.h:
+ - Added needed data members for Core Graphics port.
+
2010-08-04 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp b/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
index a01a17f..e895cee 100644
--- a/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
@@ -69,7 +69,7 @@ static void setLayerBorderColor(LayerChromium& layer, const Color& color)
static void clearBorderColor(LayerChromium& layer)
{
- layer.setBorderColor(0);
+ layer.setBorderColor(static_cast<RGBA32>(0));
}
static void setLayerBackgroundColor(LayerChromium& layer, const Color& color)
@@ -79,7 +79,7 @@ static void setLayerBackgroundColor(LayerChromium& layer, const Color& color)
static void clearLayerBackgroundColor(LayerChromium& layer)
{
- layer.setBackgroundColor(0);
+ layer.setBackgroundColor(static_cast<RGBA32>(0));
}
GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayer::compositingCoordinatesOrientation()
diff --git a/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
index 7905601..9f6ee17 100644
--- a/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
@@ -39,6 +39,13 @@
#include "PlatformContextSkia.h"
#endif
+#if PLATFORM(CG)
+#include <CoreGraphics/CGBitmapContext.h>
+#include <CoreGraphics/CGContext.h>
+#include <CoreGraphics/CGImage.h>
+#include <wtf/RetainPtr.h>
+#endif
+
namespace WebCore {
PassRefPtr<ImageLayerChromium> ImageLayerChromium::create(GraphicsLayerChromium* owner)
@@ -82,6 +89,43 @@ void ImageLayerChromium::updateTextureContents(unsigned textureId)
pixels = skiaBitmap->getPixels();
bitmapSize = IntSize(skiaBitmap->width(), skiaBitmap->height());
}
+#elif PLATFORM(CG)
+ // NativeImagePtr is a CGImageRef on Mac OS X.
+ CGImageRef cgImage = m_contents;
+ int width = CGImageGetWidth(cgImage);
+ int height = CGImageGetHeight(cgImage);
+ requiredTextureSize = IntSize(width, height);
+ bitmapSize = requiredTextureSize;
+ // FIXME: we should get rid of this temporary copy where possible.
+ int tempRowBytes = width * 4;
+ Vector<uint8_t> tempVector;
+ tempVector.resize(height * tempRowBytes);
+ // Note we do not zero this vector since we are going to
+ // completely overwrite its contents with the image below.
+ // Try to reuse the color space from the image to preserve its colors.
+ // Some images use a color space (such as indexed) unsupported by the bitmap context.
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGImageGetColorSpace(cgImage));
+ CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace.get());
+ switch (colorSpaceModel) {
+ case kCGColorSpaceModelMonochrome:
+ case kCGColorSpaceModelRGB:
+ case kCGColorSpaceModelCMYK:
+ case kCGColorSpaceModelLab:
+ case kCGColorSpaceModelDeviceN:
+ break;
+ default:
+ colorSpace.adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear));
+ break;
+ }
+ RetainPtr<CGContextRef> tempContext(AdoptCF, CGBitmapContextCreate(tempVector.data(),
+ width, height, 8, tempRowBytes,
+ colorSpace.get(),
+ kCGImageAlphaPremultipliedLast));
+ CGContextSetBlendMode(tempContext.get(), kCGBlendModeCopy);
+ CGContextDrawImage(tempContext.get(),
+ CGRectMake(0, 0, static_cast<CGFloat>(width), static_cast<CGFloat>(height)),
+ cgImage);
+ pixels = tempVector.data();
#else
#error "Need to implement for your platform."
#endif
diff --git a/WebCore/platform/graphics/chromium/LayerChromium.cpp b/WebCore/platform/graphics/chromium/LayerChromium.cpp
index 3119dd6..bba65f4 100644
--- a/WebCore/platform/graphics/chromium/LayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerChromium.cpp
@@ -56,26 +56,26 @@ PassRefPtr<LayerChromium> LayerChromium::create(GraphicsLayerChromium* owner)
}
LayerChromium::LayerChromium(GraphicsLayerChromium* owner)
- : m_needsDisplayOnBoundsChange(false)
- , m_owner(owner)
+ : m_owner(owner)
+ , m_contentsDirty(false)
, m_superlayer(0)
+ , m_anchorPoint(0.5, 0.5)
+ , m_backgroundColor(0, 0, 0, 0)
+ , m_borderColor(0, 0, 0, 0)
, m_layerRenderer(0)
+ , m_edgeAntialiasingMask(0)
+ , m_opacity(1.0)
+ , m_zPosition(0.0)
+ , m_anchorPointZ(0)
, m_borderWidth(0)
, m_allocatedTextureId(0)
- , m_borderColor(0, 0, 0, 0)
- , m_backgroundColor(0, 0, 0, 0)
- , m_anchorPoint(0.5, 0.5)
- , m_anchorPointZ(0)
, m_clearsContext(false)
, m_doubleSided(true)
- , m_edgeAntialiasingMask(0)
, m_hidden(false)
, m_masksToBounds(false)
- , m_opacity(1.0)
, m_opaque(true)
- , m_zPosition(0.0)
, m_geometryFlipped(false)
- , m_contentsDirty(false)
+ , m_needsDisplayOnBoundsChange(false)
{
}
@@ -162,6 +162,40 @@ void LayerChromium::updateTextureContents(unsigned textureId)
pixels = skiaBitmap->getPixels();
bitmapSize = IntSize(skiaBitmap->width(), skiaBitmap->height());
}
+#elif PLATFORM(CG)
+ requiredTextureSize = m_bounds;
+ IntRect boundsRect(IntPoint(0, 0), m_bounds);
+
+ // If the texture needs to be reallocated then we must redraw the entire
+ // contents of the layer.
+ if (requiredTextureSize != m_allocatedTextureSize)
+ dirtyRect = boundsRect;
+ else {
+ // Clip the dirtyRect to the size of the layer to avoid drawing outside
+ // the bounds of the backing texture.
+ dirtyRect.intersect(boundsRect);
+ }
+
+ Vector<uint8_t> tempVector;
+ int rowBytes = 4 * dirtyRect.width();
+ tempVector.resize(rowBytes * dirtyRect.height());
+ memset(tempVector.data(), 0, tempVector.size());
+ // FIXME: unsure whether this is the best color space choice.
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear));
+ RetainPtr<CGContextRef> contextCG(AdoptCF, CGBitmapContextCreate(tempVector.data(),
+ dirtyRect.width(), dirtyRect.height(), 8, rowBytes,
+ colorSpace.get(),
+ kCGImageAlphaPremultipliedLast));
+
+ GraphicsContext graphicsContext(contextCG.get());
+
+ // Translate the graphics contxt into the coordinate system of the dirty rect.
+ graphicsContext.translate(-dirtyRect.x(), -dirtyRect.y());
+
+ m_owner->paintGraphicsLayerContents(graphicsContext, dirtyRect);
+
+ pixels = tempVector.data();
+ bitmapSize = dirtyRect.size();
#else
#error "Need to implement for your platform."
#endif
@@ -187,7 +221,17 @@ void LayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize, c
} else {
ASSERT(updateRect.width() <= m_allocatedTextureSize.width() && updateRect.height() <= m_allocatedTextureSize.height());
ASSERT(updateRect.width() == bitmapSize.width() && updateRect.height() == bitmapSize.height());
+#if PLATFORM(CG)
+ // The origin is at the lower left in Core Graphics' coordinate system. We need to correct for this here.
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ updateRect.x(), m_allocatedTextureSize.height() - updateRect.height() - updateRect.y(),
+ updateRect.width(), updateRect.height(),
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+#elif PLATFORM(SKIA)
glTexSubImage2D(GL_TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+#else
+#error "Need to implement for your platform."
+#endif
}
m_dirtyRect.setSize(FloatSize());
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
index b071385..e98a65a 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
@@ -42,13 +42,17 @@
#if PLATFORM(SKIA)
#include "NativeImageSkia.h"
#include "PlatformContextSkia.h"
+#elif PLATFORM(CG)
+#include <CoreGraphics/CGBitmapContext.h>
#endif
#include <GLES2/gl2.h>
namespace WebCore {
+#ifndef NDEBUG
static WTFLogChannel LogLayerRenderer = { 0x00000000, "LayerRenderer", WTFLogChannelOn };
+#endif
static void checkGLError()
{
@@ -195,12 +199,12 @@ PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(PassOwnPtr<GLES2
}
LayerRendererChromium::LayerRendererChromium(PassOwnPtr<GLES2Context> gles2Context)
- : m_rootLayer(0)
- , m_needsDisplay(false)
+ : m_rootLayerTextureWidth(0)
+ , m_rootLayerTextureHeight(0)
, m_positionLocation(0)
, m_texCoordLocation(1)
- , m_rootLayerTextureWidth(0)
- , m_rootLayerTextureHeight(0)
+ , m_rootLayer(0)
+ , m_needsDisplay(false)
, m_scrollPosition(IntPoint(-1, -1))
, m_currentShaderProgramType(NumShaderProgramTypes)
, m_gles2Context(gles2Context)
@@ -245,6 +249,19 @@ void LayerRendererChromium::setRootLayerCanvasSize(const IntSize& size)
m_rootLayerSkiaContext->setDrawingToImageBuffer(true);
#endif
m_rootLayerGraphicsContext = new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(m_rootLayerSkiaContext.get()));
+#elif PLATFORM(CG)
+ // Release the previous CGBitmapContext before reallocating the backing store as a precaution.
+ m_rootLayerCGContext.adoptCF(0);
+ int rowBytes = 4 * size.width();
+ m_rootLayerBackingStore.resize(rowBytes * size.height());
+ memset(m_rootLayerBackingStore.data(), 0, m_rootLayerBackingStore.size());
+ // FIXME: unsure whether this is the best color space choice.
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear));
+ m_rootLayerCGContext.adoptCF(CGBitmapContextCreate(m_rootLayerBackingStore.data(),
+ size.width(), size.height(), 8, rowBytes,
+ colorSpace.get(),
+ kCGImageAlphaPremultipliedLast));
+ m_rootLayerGraphicsContext = new GraphicsContext(m_rootLayerCGContext.get());
#else
#error "Need to implement for your platform."
#endif
@@ -304,34 +321,51 @@ void LayerRendererChromium::drawLayers(const IntRect& updateRect, const IntRect&
// and viewport.
makeContextCurrent();
+ checkGLError();
+
glBindTexture(GL_TEXTURE_2D, m_rootLayerTextureId);
- unsigned visibleRectWidth = visibleRect.width();
- unsigned visibleRectHeight = visibleRect.height();
+ checkGLError();
+
+ int visibleRectWidth = visibleRect.width();
+ int visibleRectHeight = visibleRect.height();
if (visibleRectWidth != m_rootLayerTextureWidth || visibleRectHeight != m_rootLayerTextureHeight) {
m_rootLayerTextureWidth = visibleRect.width();
m_rootLayerTextureHeight = visibleRect.height();
m_projectionMatrix = orthoMatrix(0, visibleRectWidth + 0.5, visibleRectHeight + 0.5, 0, -1000, 1000);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_rootLayerTextureWidth, m_rootLayerTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+
+ checkGLError();
}
// The GL viewport covers the entire visible area, including the scrollbars.
glViewport(0, 0, visibleRectWidth, visibleRectHeight);
+ checkGLError();
+
// The layer, scroll and debug border shaders all use the same vertex attributes
// so we can bind them only once.
glBindBuffer(GL_ARRAY_BUFFER, m_quadVboIds[Vertices]);
+ checkGLError();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_quadVboIds[LayerElements]);
+ checkGLError();
GLuint offset = 0;
glVertexAttribPointer(m_positionLocation, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(offset));
+ checkGLError();
offset += 3 * sizeof(GLfloat);
glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(offset));
+ checkGLError();
glEnableVertexAttribArray(m_positionLocation);
+ checkGLError();
glEnableVertexAttribArray(m_texCoordLocation);
+ checkGLError();
glActiveTexture(GL_TEXTURE0);
+ checkGLError();
glDisable(GL_DEPTH_TEST);
+ checkGLError();
glDisable(GL_CULL_FACE);
+ checkGLError();
if (m_scrollPosition == IntPoint(-1, -1))
m_scrollPosition = scrollPosition;
@@ -346,15 +380,28 @@ void LayerRendererChromium::drawLayers(const IntRect& updateRect, const IntRect&
// root layer texture. The newly exposed area is subesquently filled as usual with
// the contents of the updateRect.
TransformationMatrix scrolledLayerMatrix;
+#if PLATFORM(SKIA)
+ float scaleFactor = 1.0f;
+#elif PLATFORM(CG)
+ // Because the contents of the OpenGL texture are inverted
+ // vertically compared to the Skia backend, we need to move
+ // the backing store in the opposite direction.
+ float scaleFactor = -1.0f;
+#else
+#error "Need to implement for your platform."
+#endif
+
scrolledLayerMatrix.translate3d((int)floorf(0.5 * visibleRect.width() + 0.5) - scrollDelta.x(),
- (int)floorf(0.5 * visibleRect.height() + 0.5) + scrollDelta.y(), 0);
+ (int)floorf(0.5 * visibleRect.height() + 0.5) + scaleFactor * scrollDelta.y(), 0);
scrolledLayerMatrix.scale3d(1, -1, 1);
// Switch shaders to avoid RGB swizzling.
useShaderProgram(ScrollLayerProgram);
glUniform1i(m_shaderPrograms[ScrollLayerProgram].m_samplerLocation, 0);
+ checkGLError();
drawTexturedQuad(scrolledLayerMatrix, visibleRect.width(), visibleRect.height(), 1);
+ checkGLError();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, contentRect.width(), contentRect.height());
@@ -381,31 +428,52 @@ void LayerRendererChromium::drawLayers(const IntRect& updateRect, const IntRect&
// Copy the contents of the updated rect to the root layer texture.
glTexSubImage2D(GL_TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GL_RGBA, GL_UNSIGNED_BYTE, pixels);
checkGLError();
+#elif PLATFORM(CG)
+ // Get the contents of the updated rect.
+ ASSERT(static_cast<int>(CGBitmapContextGetWidth(m_rootLayerCGContext.get())) == updateRect.width() && static_cast<int>(CGBitmapContextGetHeight(m_rootLayerCGContext.get())) == updateRect.height());
+ void* pixels = m_rootLayerBackingStore.data();
+
+ checkGLError();
+ // Copy the contents of the updated rect to the root layer texture.
+ // The origin is at the lower left in Core Graphics' coordinate system. We need to correct for this here.
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ updateRect.x(), m_rootLayerTextureHeight - updateRect.y() - updateRect.height(),
+ updateRect.width(), updateRect.height(),
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ checkGLError();
#else
-#error Must port to your platform
+#error "Need to implement for your platform."
#endif
}
glClearColor(0, 0, 1, 1);
+ checkGLError();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ checkGLError();
// Render the root layer using a quad that takes up the entire visible area of the window.
useShaderProgram(ContentLayerProgram);
+ checkGLError();
glUniform1i(m_samplerLocation, 0);
+ checkGLError();
TransformationMatrix layerMatrix;
layerMatrix.translate3d(visibleRect.width() / 2, visibleRect.height() / 2, 0);
drawTexturedQuad(layerMatrix, visibleRect.width(), visibleRect.height(), 1);
+ checkGLError();
// If culling is enabled then we will cull the backface.
glCullFace(GL_BACK);
+ checkGLError();
// The orthographic projection is setup such that Y starts at zero and
// increases going down the page so we need to adjust the winding order of
// front facing triangles.
glFrontFace(GL_CW);
+ checkGLError();
// The shader used to render layers returns pre-multiplied alpha colors
// so we need to send the blending mode appropriately.
glEnable(GL_BLEND);
+ checkGLError();
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
checkGLError();
@@ -668,6 +736,9 @@ bool LayerRendererChromium::initializeSharedGLObjects()
" gl_Position = matrix * a_position; \n"
" v_texCoord = a_texCoord; \n"
"} \n";
+ // Note differences between Skia and Core Graphics versions:
+ // - Skia uses BGRA and origin is upper left
+ // - Core Graphics uses RGBA and origin is lower left
char fragmentShaderString[] =
"precision mediump float; \n"
"varying vec2 v_texCoord; \n"
@@ -675,8 +746,15 @@ bool LayerRendererChromium::initializeSharedGLObjects()
"uniform float alpha; \n"
"void main() \n"
"{ \n"
+#if PLATFORM(SKIA)
" vec4 texColor = texture2D(s_texture, v_texCoord); \n"
" gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha; \n"
+#elif PLATFORM(CG)
+ " vec4 texColor = texture2D(s_texture, vec2(v_texCoord.x, 1.0 - v_texCoord.y)); \n"
+ " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha; \n"
+#else
+#error "Need to implement for your platform."
+#endif
"} \n";
// Fragment shader used for rendering the scrolled root layer quad. It differs
@@ -775,7 +853,7 @@ bool LayerRendererChromium::initializeSharedGLObjects()
// Create a texture object to hold the contents of the root layer.
m_rootLayerTextureId = createLayerTexture();
- if (m_rootLayerTextureId == -1) {
+ if (!m_rootLayerTextureId) {
LOG_ERROR("Failed to create texture for root layer");
return false;
}
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
index 3b89dc6..17e7e57 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.h
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
@@ -42,6 +42,11 @@
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
+#if PLATFORM(CG)
+#include <CoreGraphics/CGContext.h>
+#include <wtf/RetainPtr.h>
+#endif
+
namespace WebCore {
class GLES2Context;
@@ -145,7 +150,12 @@ private:
OwnPtr<skia::PlatformCanvas> m_rootLayerCanvas;
OwnPtr<PlatformContextSkia> m_rootLayerSkiaContext;
OwnPtr<GraphicsContext> m_rootLayerGraphicsContext;
+#elif PLATFORM(CG)
+ Vector<uint8_t> m_rootLayerBackingStore;
+ RetainPtr<CGContextRef> m_rootLayerCGContext;
+ OwnPtr<GraphicsContext> m_rootLayerGraphicsContext;
#endif
+
IntSize m_rootLayerCanvasSize;
OwnPtr<GLES2Context> m_gles2Context;
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 1a4bd36..d19f902 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-02 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Dimitri Glazkov.
+
+ Port Chromium's accelerated compositing to Mac OS X
+ https://bugs.webkit.org/show_bug.cgi?id=43398
+
+ * public/WebGLES2Context.h:
+ - Added resizeOnscreenContent, needed on Mac OS X to report
+ window size changes.
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::resize):
+ - Send resize notification to the WebGLES2Context.
+ (WebKit::WebViewImpl::updateRootLayerContents):
+ - Ported to Core Graphics.
+ (WebKit::WebViewImpl::gles2Context):
+ - Added initial size notification upon context creation.
+
2010-08-04 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Yury Semikhatsky.
diff --git a/WebKit/chromium/public/WebGLES2Context.h b/WebKit/chromium/public/WebGLES2Context.h
index c67faf2..45184aa 100644
--- a/WebKit/chromium/public/WebGLES2Context.h
+++ b/WebKit/chromium/public/WebGLES2Context.h
@@ -58,6 +58,12 @@ public:
// Returns the ID of the texture used for offscreen rendering in the context of the parent.
virtual unsigned getOffscreenContentParentTextureId() = 0;
+
+ // The following function is used only on Mac OS X and is needed
+ // in order to report window size changes.
+#if defined(__APPLE__)
+ virtual void resizeOnscreenContent(const WebSize&) = 0;
+#endif
};
} // namespace WebKit
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index 691f143..85dab4b 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -911,6 +911,13 @@ void WebViewImpl::resize(const WebSize& newSize)
WebRect damagedRect(0, 0, m_size.width, m_size.height);
m_client->didInvalidateRect(damagedRect);
}
+
+#if OS(DARWIN)
+ if (m_gles2Context) {
+ m_gles2Context->resizeOnscreenContent(WebSize(std::max(1, m_size.width),
+ std::max(1, m_size.height)));
+ }
+#endif
}
void WebViewImpl::layout()
@@ -2154,6 +2161,22 @@ void WebViewImpl::updateRootLayerContents(const WebRect& rect)
rootLayerContext->restore();
platformCanvas->restore();
+#elif PLATFORM(CG)
+ CGContextRef cgContext = rootLayerContext->platformContext();
+
+ CGContextSaveGState(cgContext);
+
+ // Bring the CoreGraphics context into the coordinate system of the paint rect.
+ CGContextTranslateCTM(cgContext, -rect.x, -rect.y);
+
+ rootLayerContext->save();
+
+ webframe->paintWithContext(*rootLayerContext, rect);
+ rootLayerContext->restore();
+
+ CGContextRestoreGState(cgContext);
+#else
+#error Must port to your platform
#endif
}
}
@@ -2203,6 +2226,11 @@ WebGLES2Context* WebViewImpl::gles2Context()
m_gles2Context.clear();
return 0;
}
+
+#if OS(DARWIN)
+ m_gles2Context->resizeOnscreenContent(WebSize(std::max(1, m_size.width),
+ std::max(1, m_size.height)));
+#endif
}
return m_gles2Context.get();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list