[Chromium] Solid color layers should respect opacity value.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Apr 2012 23:32:44 +0000 (23:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Apr 2012 23:32:44 +0000 (23:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84197

Patch by David Reveman <reveman@chromium.org> on 2012-04-18
Reviewed by Adrienne Walker.

Source/WebCore:

Fold opacity into shader color for solid color layers.

Test: CCSolidColorLayerImplTest.verifyCorrectOpacityInQuad

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawSolidColorQuad):

Source/WebKit/chromium:

* tests/CCSolidColorLayerImplTest.cpp:
(CCLayerTestCommon::TEST):
(CCLayerTestCommon):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@114580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp

index 3eac608..bc85395 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-18  David Reveman  <reveman@chromium.org>
+
+        [Chromium] Solid color layers should respect opacity value.
+        https://bugs.webkit.org/show_bug.cgi?id=84197
+
+        Reviewed by Adrienne Walker.
+
+        Fold opacity into shader color for solid color layers.
+
+        Test: CCSolidColorLayerImplTest.verifyCorrectOpacityInQuad
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawSolidColorQuad):
+
 2012-04-18  Mark Pilgrim  <pilgrim@chromium.org>
 
         [Chromium] Call prefetchDNS directly
index a3eb1cd..7fa3c35 100644 (file)
@@ -627,13 +627,13 @@ void LayerRendererChromium::drawSolidColorQuad(const CCSolidColorDrawQuad* quad)
     tileTransform.translate(tileRect.x() + tileRect.width() / 2.0, tileRect.y() + tileRect.height() / 2.0);
 
     const Color& color = quad->color();
-    float alpha = color.alpha() / 255.0;
+    float opacity = quad->opacity();
+    float alpha = (color.alpha() / 255.0) * opacity;
 
     GLC(context(), context()->uniform4f(solidColorProgram->fragmentShader().colorLocation(), (color.red() / 255.0) * alpha, (color.green() / 255.0) * alpha, (color.blue() / 255.0) * alpha, alpha));
 
-    float opacity = quad->opacity();
     drawTexturedQuad(tileTransform,
-                     tileRect.width(), tileRect.height(), opacity, FloatQuad(),
+                     tileRect.width(), tileRect.height(), 1.0, FloatQuad(),
                      solidColorProgram->vertexShader().matrixLocation(),
                      -1, -1);
 }
index 3ee091d..bc42eda 100644 (file)
@@ -1,3 +1,14 @@
+2012-04-18  David Reveman  <reveman@chromium.org>
+
+        [Chromium] Solid color layers should respect opacity value.
+        https://bugs.webkit.org/show_bug.cgi?id=84197
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCSolidColorLayerImplTest.cpp:
+        (CCLayerTestCommon::TEST):
+        (CCLayerTestCommon):
+
 2012-04-18  Mark Pilgrim  <pilgrim@chromium.org>
 
         [Chromium] Call prefetchDNS directly
index a55a447..6b71249 100644 (file)
@@ -81,4 +81,27 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
     EXPECT_EQ(quadCuller.quadList()[0]->toSolidColorDrawQuad()->color(), testColor);
 }
 
+TEST(CCSolidColorLayerImplTest, verifyCorrectOpacityInQuad)
+{
+    DebugScopedSetImplThread scopedImplThread;
+
+    const float opacity = 0.5f;
+
+    MockCCQuadCuller quadCuller;
+    IntSize layerSize = IntSize(100, 100);
+    IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
+
+    OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
+    layer->setVisibleLayerRect(visibleLayerRect);
+    layer->setBounds(layerSize);
+    layer->setDrawOpacity(opacity);
+
+    OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
+    bool hadMissingTiles = false;
+    layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles);
+
+    ASSERT_EQ(quadCuller.quadList().size(), 1U);
+    EXPECT_EQ(opacity, quadCuller.quadList()[0]->toSolidColorDrawQuad()->opacity());
+}
+
 } // namespace