Diff
Modified: trunk/Source/Platform/ChangeLog (119886 => 119887)
--- trunk/Source/Platform/ChangeLog 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/Platform/ChangeLog 2012-06-09 02:29:09 UTC (rev 119887)
@@ -1,3 +1,15 @@
+2012-06-08 David Reveman <[email protected]>
+
+ [Chromium] Compositor doesn't support translucent root layers.
+ https://bugs.webkit.org/show_bug.cgi?id=87821
+
+ Reviewed by James Robinson.
+
+ * chromium/public/WebLayer.h:
+ (WebLayer):
+ * chromium/public/WebLayerTreeView.h:
+ (WebLayerTreeView):
+
2012-06-06 Mark Pilgrim <[email protected]>
[Chromium] Move createMessagePortChannel to Platform.h
Modified: trunk/Source/Platform/chromium/public/WebLayer.h (119886 => 119887)
--- trunk/Source/Platform/chromium/public/WebLayer.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/Platform/chromium/public/WebLayer.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -116,9 +116,9 @@
// Apply filters to pixels that show through the background of this layer.
// Note: These filters are only possible on layers that are drawn directly
- // to the root render surface. This means if an ancestor of the background-
- // filtered layer sets certain properties (opacity, transforms), it may
- // conflict and hide the background filters.
+ // to a root render surface with an opaque background. This means if an
+ // ancestor of the background-filtered layer sets certain properties
+ // (opacity, transforms), it may conflict and hide the background filters.
WEBKIT_EXPORT void setBackgroundFilters(const WebFilterOperations&);
WEBKIT_EXPORT void setDebugBorderColor(const WebColor&);
Modified: trunk/Source/Platform/chromium/public/WebLayerTreeView.h (119886 => 119887)
--- trunk/Source/Platform/chromium/public/WebLayerTreeView.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/Platform/chromium/public/WebLayerTreeView.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -118,6 +118,9 @@
// Sets the background color for the viewport.
WEBKIT_EXPORT void setBackgroundColor(WebColor);
+ // Sets the background transparency for the viewport. The default is 'false'.
+ WEBKIT_EXPORT void setHasTransparentBackground(bool);
+
// Sets whether this view is visible. In threaded mode, a view that is not visible will not
// composite or trigger updateAnimations() or layout() calls until it becomes visible.
WEBKIT_EXPORT void setVisible(bool);
Modified: trunk/Source/WebCore/ChangeLog (119886 => 119887)
--- trunk/Source/WebCore/ChangeLog 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/ChangeLog 2012-06-09 02:29:09 UTC (rev 119887)
@@ -1,3 +1,51 @@
+2012-06-08 David Reveman <[email protected]>
+
+ [Chromium] Compositor doesn't support translucent root layers.
+ https://bugs.webkit.org/show_bug.cgi?id=87821
+
+ Reviewed by James Robinson.
+
+ Forward the isTransparent WebView setting to WebLayerTreeView,
+ CCLayerTreeHost and CCLayerTreeHostImpl as hasTransparentBackground.
+ Use hasTransparentBackground setting to determine how to clear the
+ root render pass and draw the background. Set opaque flag correctly
+ on the NonCompositedContentHost's graphics layer to make sure
+ sub-pixel rendering is not used with a transparent WebView.
+
+ Unit tests: CCLayerTreeHostImplTest.hasTransparentBackground
+ LayerRendererChromiumTest2.opaqueRenderPass
+ LayerRendererChromiumTest2.transparentRenderPass
+
+ * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
+ (WebCore::BitmapCanvasLayerTextureUpdater::prepareToUpdate):
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::clearRenderPass):
+ (WebCore::LayerRendererChromium::drawRenderPass):
+ (WebCore::LayerRendererChromium::drawBackgroundFilters):
+ * platform/graphics/chromium/LayerRendererChromium.h:
+ (LayerRendererChromium):
+ * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp:
+ (WebCore::SkPictureCanvasLayerTextureUpdater::prepareToUpdate):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::CCLayerTreeHost):
+ (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+ (WebCore::CCLayerTreeHost::setHasTransparentBackground):
+ (CCLayerTreeHost):
+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+ (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+ (WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+ (WebCore::CCLayerTreeHostImpl::hasTransparentBackground):
+ (WebCore::CCLayerTreeHostImpl::setHasTransparentBackground):
+ (CCLayerTreeHostImpl):
+ * platform/graphics/chromium/cc/CCRenderPass.cpp:
+ (WebCore::CCRenderPass::CCRenderPass):
+ * platform/graphics/chromium/cc/CCRenderPass.h:
+ (WebCore::CCRenderPass::hasTransparentBackground):
+ (WebCore::CCRenderPass::setHasTransparentBackground):
+ (CCRenderPass):
+
2012-06-08 Ian Vollick <[email protected]>
[chromium] Single thread proxy's animation timer should short circuit if the layer renderer has not been initialized
Modified: trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -88,8 +88,9 @@
// Assumption: if a tiler is using border texels, then it is because the
// layer is likely to be filtered or transformed. Because of it might be
// transformed, draw the text in grayscale instead of subpixel antialiasing.
+ bool useGrayscaleText = borderTexels || !layerIsOpaque;
PlatformCanvas::Painter::TextOption textOption =
- borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
+ useGrayscaleText ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
PlatformCanvas::Painter canvasPainter(&m_canvas, textOption);
canvasPainter.skiaContext()->setTrackOpaqueRegion(!layerIsOpaque);
paintContents(*canvasPainter.context(), *canvasPainter.skiaContext(), contentRect, contentsScale, resultingOpaqueRect);
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -402,15 +402,14 @@
m_currentRenderPass = 0;
}
-void LayerRendererChromium::clearRenderPass(const CCRenderPass* renderPass, const CCRenderPass* rootRenderPass, const FloatRect& framebufferDamageRect)
+void LayerRendererChromium::clearRenderPass(const CCRenderPass* renderPass, const FloatRect& framebufferDamageRect)
{
- // Non-root layers should clear their entire contents to transparent. On DEBUG builds, the root layer
- // is cleared to blue to easily see regions that were not drawn on the screen. If we
+ // On DEBUG builds, opaque render passes are cleared to blue to easily see regions that were not drawn on the screen. If we
// are using partial swap / scissor optimization, then the surface should only
// clear the damaged region, so that we don't accidentally clear un-changed portions
// of the screen.
- if (renderPass != rootRenderPass)
+ if (renderPass->hasTransparentBackground())
GLC(m_context, m_context->clearColor(0, 0, 0, 0));
else
GLC(m_context, m_context->clearColor(0, 0, 1, 1));
@@ -421,7 +420,7 @@
GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
#if defined(NDEBUG)
- if (renderPass != rootRenderPass)
+ if (renderPass->hasTransparentBackground())
#endif
m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
@@ -475,7 +474,7 @@
if (!useRenderPass(renderPass))
return;
- clearRenderPass(renderPass, m_defaultRenderPass, framebufferDamageRect);
+ clearRenderPass(renderPass, framebufferDamageRect);
const CCQuadList& quadList = renderPass->quadList();
for (CCQuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it)
@@ -615,10 +614,11 @@
if (quad->backgroundFilters().isEmpty())
return;
- // FIXME: We only allow background filters on the root render surface because other surfaces may contain
+ // FIXME: We only allow background filters on an opaque render surface because other surfaces may contain
// translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied.
- if (!isCurrentRenderPass(m_defaultRenderPass))
+ if (m_currentRenderPass->hasTransparentBackground())
return;
+ ASSERT(!m_currentManagedTexture);
// FIXME: Do a single readback for both the surface and replica and cache the filtered results (once filter textures are not reused).
IntRect deviceRect = enclosingIntRect(CCMathUtil::mapClippedRect(contentsDeviceTransform, sharedGeometryQuad().boundingBox()));
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -152,7 +152,7 @@
bool bindFramebufferToTexture(ManagedTexture*, const IntRect& viewportRect);
- void clearRenderPass(const CCRenderPass*, const CCRenderPass* rootRenderPass, const FloatRect& framebufferDamageRect);
+ void clearRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect);
void releaseRenderPassTextures();
Modified: trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -58,7 +58,8 @@
// layer is likely to be filtered or transformed. Because it might be
// transformed, set image buffer flag to draw the text in grayscale
// instead of using subpixel antialiasing.
- platformContext.setDrawingToImageBuffer(borderTexels ? true : false);
+ bool useGrayscaleText = borderTexels || !m_layerIsOpaque;
+ platformContext.setDrawingToImageBuffer(useGrayscaleText);
GraphicsContext graphicsContext(&platformContext);
paintContents(graphicsContext, platformContext, contentRect, contentsScale, resultingOpaqueRect);
m_picture.endRecording();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -86,6 +86,7 @@
, m_maxPageScaleFactor(1)
, m_triggerIdlePaints(true)
, m_backgroundColor(Color::white)
+ , m_hasTransparentBackground(false)
, m_partialTextureUpdateRequests(0)
{
ASSERT(CCProxy::isMainThread());
@@ -252,6 +253,7 @@
hostImpl->setViewportSize(viewportSize());
hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFactor, m_maxPageScaleFactor);
hostImpl->setBackgroundColor(m_backgroundColor);
+ hostImpl->setHasTransparentBackground(m_hasTransparentBackground);
hostImpl->setVisible(m_visible);
hostImpl->setSourceFrameCanBeDrawn(m_frameIsForDisplay);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -231,6 +231,8 @@
void setBackgroundColor(const Color& color) { m_backgroundColor = color; }
+ void setHasTransparentBackground(bool transparent) { m_hasTransparentBackground = transparent; }
+
TextureManager* contentsTextureManager() const;
void setContentsMemoryAllocationLimitBytes(size_t);
@@ -309,6 +311,7 @@
float m_minPageScaleFactor, m_maxPageScaleFactor;
bool m_triggerIdlePaints;
Color m_backgroundColor;
+ bool m_hasTransparentBackground;
TextureList m_deleteTextureAfterCommitList;
size_t m_partialTextureUpdateRequests;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -124,6 +124,7 @@
, m_sentPageScaleDelta(1)
, m_minPageScale(0)
, m_maxPageScale(0)
+ , m_hasTransparentBackground(false)
, m_needsAnimateLayers(false)
, m_pinchGestureActive(false)
, m_fpsCounter(CCFrameRateCounter::create())
@@ -321,7 +322,10 @@
occlusionTracker.leaveLayer(it);
}
- passes.last()->appendQuadsToFillScreen(m_rootLayerImpl.get(), m_backgroundColor, occlusionTracker);
+ if (!m_hasTransparentBackground) {
+ passes.last()->setHasTransparentBackground(false);
+ passes.last()->appendQuadsToFillScreen(m_rootLayerImpl.get(), m_backgroundColor, occlusionTracker);
+ }
if (drawFrame)
occlusionTracker.overdrawMetrics().recordMetrics(this);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -160,6 +160,9 @@
const Color& backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(const Color& color) { m_backgroundColor = color; }
+ bool hasTransparentBackground() const { return m_hasTransparentBackground; }
+ void setHasTransparentBackground(bool transparent) { m_hasTransparentBackground = transparent; }
+
bool needsAnimateLayers() const { return m_needsAnimateLayers; }
void setNeedsAnimateLayers() { m_needsAnimateLayers = true; }
@@ -228,6 +231,7 @@
float m_minPageScale, m_maxPageScale;
Color m_backgroundColor;
+ bool m_hasTransparentBackground;
// If this is true, it is necessary to traverse the layer tree ticking the animators.
bool m_needsAnimateLayers;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -45,6 +45,7 @@
CCRenderPass::CCRenderPass(CCRenderSurface* targetSurface)
: m_targetSurface(targetSurface)
, m_framebufferOutputRect(targetSurface->contentRect())
+ , m_hasTransparentBackground(true)
{
ASSERT(m_targetSurface);
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h (119886 => 119887)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -64,6 +64,9 @@
// This denotes the bounds in physical pixels of the output generated by this RenderPass.
const IntRect& framebufferOutputRect() const { return m_framebufferOutputRect; }
+ bool hasTransparentBackground() const { return m_hasTransparentBackground; }
+ void setHasTransparentBackground(bool transparent) { m_hasTransparentBackground = transparent; }
+
private:
explicit CCRenderPass(CCRenderSurface*);
@@ -71,6 +74,7 @@
CCQuadList m_quadList;
IntRect m_framebufferOutputRect;
Vector<OwnPtr<CCSharedQuadState> > m_sharedQuadStateList;
+ bool m_hasTransparentBackground;
};
typedef Vector<OwnPtr<CCRenderPass> > CCRenderPassList;
Modified: trunk/Source/WebKit/chromium/ChangeLog (119886 => 119887)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-09 02:29:09 UTC (rev 119887)
@@ -1,3 +1,29 @@
+2012-06-08 David Reveman <[email protected]>
+
+ [Chromium] Compositor doesn't support translucent root layers.
+ https://bugs.webkit.org/show_bug.cgi?id=87821
+
+ Reviewed by James Robinson.
+
+ * src/NonCompositedContentHost.cpp:
+ (WebKit::NonCompositedContentHost::setOpaque):
+ (WebKit):
+ * src/NonCompositedContentHost.h:
+ (NonCompositedContentHost):
+ * src/WebLayerTreeView.cpp:
+ (WebKit::WebLayerTreeView::setHasTransparentBackground):
+ (WebKit):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::setIsTransparent):
+ (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+ * tests/CCLayerTreeHostImplTest.cpp:
+ * tests/LayerRendererChromiumTest.cpp:
+ (ClearCountingContext):
+ (ClearCountingContext::ClearCountingContext):
+ (ClearCountingContext::clear):
+ (ClearCountingContext::clearCount):
+ (TEST):
+
2012-06-08 Ian Vollick <[email protected]>
[chromium] Single thread proxy's animation timer should short circuit if the layer renderer has not been initialized
Modified: trunk/Source/WebKit/chromium/src/NonCompositedContentHost.cpp (119886 => 119887)
--- trunk/Source/WebKit/chromium/src/NonCompositedContentHost.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/src/NonCompositedContentHost.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -62,6 +62,11 @@
m_graphicsLayer->platformLayer()->setBackgroundColor(color);
}
+void NonCompositedContentHost::setOpaque(bool opaque)
+{
+ m_graphicsLayer->platformLayer()->setOpaque(opaque);
+}
+
void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer)
{
m_graphicsLayer->setNeedsDisplay();
Modified: trunk/Source/WebKit/chromium/src/NonCompositedContentHost.h (119886 => 119887)
--- trunk/Source/WebKit/chromium/src/NonCompositedContentHost.h 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/src/NonCompositedContentHost.h 2012-06-09 02:29:09 UTC (rev 119887)
@@ -56,6 +56,7 @@
void invalidateRect(const WebCore::IntRect&);
void setBackgroundColor(const WebCore::Color&);
+ void setOpaque(bool);
void setScrollLayer(WebCore::GraphicsLayer*);
void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float deviceScale, int layerAdjustX);
WebCore::GraphicsLayer* topLevelRootLayer() const { return m_graphicsLayer.get(); }
Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp (119886 => 119887)
--- trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -107,6 +107,11 @@
m_private->layerTreeHost()->setBackgroundColor(color);
}
+void WebLayerTreeView::setHasTransparentBackground(bool transparent)
+{
+ m_private->layerTreeHost()->setHasTransparentBackground(transparent);
+}
+
void WebLayerTreeView::setVisible(bool visible)
{
m_private->layerTreeHost()->setVisible(visible);
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (119886 => 119887)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -3026,6 +3026,11 @@
// Future frames check this to know whether to be transparent.
m_isTransparent = isTransparent;
+
+ if (m_nonCompositedContentHost)
+ m_nonCompositedContentHost->setOpaque(!isTransparent);
+
+ m_layerTreeView.setHasTransparentBackground(isTransparent);
}
bool WebViewImpl::isTransparent() const
@@ -3475,6 +3480,7 @@
m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this));
m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders());
+ m_nonCompositedContentHost->setOpaque(!isTransparent());
if (m_webSettings->applyDefaultDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) {
ASSERT(page()->deviceScaleFactor());
@@ -3489,6 +3495,7 @@
m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
if (m_compositorSurfaceReady)
m_layerTreeView.setSurfaceReady();
+ m_layerTreeView.setHasTransparentBackground(isTransparent());
updateLayerTreeViewport();
m_client->didActivateCompositor(m_layerTreeView.compositorIdentifier());
m_isAcceleratedCompositingActive = true;
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (119886 => 119887)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -1775,4 +1775,39 @@
m_hostImpl->swapBuffers();
}
+class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D {
+public:
+ MOCK_METHOD1(useProgram, void(WebGLId program));
+ MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset));
+};
+
+TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground)
+{
+ MockDrawQuadsToFillScreenContext* mockContext = new MockDrawQuadsToFillScreenContext();
+ RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(mockContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+
+ // Run test case
+ OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context, CCLayerImpl::create(1));
+ myHostImpl->setBackgroundColor(Color::white);
+
+ // Verify one quad is drawn when transparent background set is not set.
+ myHostImpl->setHasTransparentBackground(false);
+ EXPECT_CALL(*mockContext, useProgram(_))
+ .Times(1);
+ EXPECT_CALL(*mockContext, drawElements(_, _, _, _))
+ .Times(1);
+ CCLayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ Mock::VerifyAndClearExpectations(&mockContext);
+
+ // Verify no quads are drawn when transparent background is set.
+ myHostImpl->setHasTransparentBackground(true);
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ Mock::VerifyAndClearExpectations(&mockContext);
+}
+
} // namespace
Modified: trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp (119886 => 119887)
--- trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp 2012-06-09 02:26:36 UTC (rev 119886)
+++ trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp 2012-06-09 02:29:09 UTC (rev 119887)
@@ -357,3 +357,58 @@
EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul);
}
+
+class ClearCountingContext : public FakeWebGraphicsContext3D {
+public:
+ ClearCountingContext() : m_clear(0) { }
+
+ virtual void clear(WGC3Dbitfield)
+ {
+ m_clear++;
+ }
+
+ int clearCount() const { return m_clear; }
+
+private:
+ int m_clear;
+};
+
+TEST(LayerRendererChromiumTest2, opaqueBackground)
+{
+ FakeCCRendererClient mockClient;
+ RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ClearCountingContext), GraphicsContext3D::RenderDirectlyToHostWindow);
+ FakeLayerRendererChromium layerRendererChromium(&mockClient, context);
+
+ mockClient.rootRenderPass()->setHasTransparentBackground(false);
+
+ EXPECT_TRUE(layerRendererChromium.initialize());
+
+ layerRendererChromium.beginDrawingFrame(mockClient.rootRenderPass());
+ layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect());
+ layerRendererChromium.finishDrawingFrame();
+
+ // On DEBUG builds, render passes with opaque background clear to blue to
+ // easily see regions that were not drawn on the screen.
+#if defined(NDEBUG)
+ EXPECT_EQ(0, static_cast<ClearCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()))->clearCount());
+#else
+ EXPECT_EQ(1, static_cast<ClearCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()))->clearCount());
+#endif
+}
+
+TEST(LayerRendererChromiumTest2, transparentBackground)
+{
+ FakeCCRendererClient mockClient;
+ RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ClearCountingContext), GraphicsContext3D::RenderDirectlyToHostWindow);
+ FakeLayerRendererChromium layerRendererChromium(&mockClient, context);
+
+ mockClient.rootRenderPass()->setHasTransparentBackground(true);
+
+ EXPECT_TRUE(layerRendererChromium.initialize());
+
+ layerRendererChromium.beginDrawingFrame(mockClient.rootRenderPass());
+ layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect());
+ layerRendererChromium.finishDrawingFrame();
+
+ EXPECT_EQ(1, static_cast<ClearCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()))->clearCount());
+}