Title: [107611] trunk
Revision
107611
Author
[email protected]
Date
2012-02-13 14:22:49 -0800 (Mon, 13 Feb 2012)

Log Message

Source/WebCore: [chromium] Implement Brightness and Contrast filters on composited
layers.  Fix Saturation filter.
https://bugs.webkit.org/show_bug.cgi?id=78527

Reviewed by Kenneth Russell.

Will be covered by existing tests in css3/filters, when enabled.

* platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp:
(WebCore::CCRenderSurfaceFilters::apply):

LayoutTests: Unskip the css3/filters tests, so we can get some baselines off the
bots.
https://bugs.webkit.org/show_bug.cgi?id=78527

Reviewed by Kenneth Russell.

* platform/chromium/test_expectations.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107610 => 107611)


--- trunk/LayoutTests/ChangeLog	2012-02-13 22:21:23 UTC (rev 107610)
+++ trunk/LayoutTests/ChangeLog	2012-02-13 22:22:49 UTC (rev 107611)
@@ -1,3 +1,13 @@
+2012-02-13  Stephen White  <[email protected]>
+
+        Unskip the css3/filters tests, so we can get some baselines off the
+        bots.
+        https://bugs.webkit.org/show_bug.cgi?id=78527
+
+        Reviewed by Kenneth Russell.
+
+        * platform/chromium/test_expectations.txt:
+
 2012-02-13  Brady Eidson  <[email protected]>
 
         <rdar://problem/7196487> and https://bugs.webkit.org/show_bug.cgi?id=26777

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (107610 => 107611)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-13 22:21:23 UTC (rev 107610)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-13 22:22:49 UTC (rev 107611)
@@ -3163,7 +3163,7 @@
 BUGWK74137 : fast/regions/webkit-flow-inlines-inside-regions-bounds.html = PASS FAIL MISSING
 
 // CSS Filters support not yet enabled
-BUGWK68469 SKIP : css3/filters = PASS
+BUGWK68469 : css3/filters = FAIL
 
 // <style scoped> not yet enabled.
 BUGWK49142 SKIP : fast/css/style-scoped = PASS

Modified: trunk/Source/WebCore/ChangeLog (107610 => 107611)


--- trunk/Source/WebCore/ChangeLog	2012-02-13 22:21:23 UTC (rev 107610)
+++ trunk/Source/WebCore/ChangeLog	2012-02-13 22:22:49 UTC (rev 107611)
@@ -1,3 +1,16 @@
+2012-02-13  Stephen White  <[email protected]>
+
+        [chromium] Implement Brightness and Contrast filters on composited
+        layers.  Fix Saturation filter.
+        https://bugs.webkit.org/show_bug.cgi?id=78527
+
+        Reviewed by Kenneth Russell.
+
+        Will be covered by existing tests in css3/filters, when enabled.
+
+        * platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp:
+        (WebCore::CCRenderSurfaceFilters::apply):
+
 2012-02-13  Anders Carlsson  <[email protected]>
 
         Turn off edge antialiasing for tile cache tile layers

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp (107610 => 107611)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp	2012-02-13 22:21:23 UTC (rev 107610)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp	2012-02-13 22:22:49 UTC (rev 107611)
@@ -38,6 +38,29 @@
 
 namespace {
 
+void getBrightnessMatrix(float amount, SkScalar matrix[20])
+{
+    memset(matrix, 0, 20 * sizeof(SkScalar));
+    //    Old implementation, a la the draft spec, a straight-up scale,
+    //    representing <feFunc[R|G|B] type="linear" slope="[amount]">
+    //    (See http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#brightnessEquivalent)
+    // matrix[0] = matrix[6] = matrix[12] = amount;
+    // matrix[18] = 1;
+    //    New implementation, a translation in color space, representing
+    //    <feFunc[R|G|B] type="linear" intercept="[amount]"/>
+    //    (See https://www.w3.org/Bugs/Public/show_bug.cgi?id=15647)
+    matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1;
+    matrix[4] = matrix[9] = matrix[14] = amount * 255;
+}
+
+void getContrastMatrix(float amount, SkScalar matrix[20])
+{
+    memset(matrix, 0, 20 * sizeof(SkScalar));
+    matrix[0] = matrix[6] = matrix[12] = amount;
+    matrix[4] = matrix[9] = matrix[14] = (-0.5f * amount + 0.5f) * 255;
+    matrix[18] = 1;
+}
+
 void getSaturateMatrix(float amount, SkScalar matrix[20])
 {
     matrix[0] = 0.213f + 0.787f * amount;
@@ -188,6 +211,20 @@
         SkCanvas canvas(&device);
         canvas.clear(0x0);
         switch (filterOperation->getOperationType()) {
+        case FilterOperation::BRIGHTNESS: {
+            const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+            SkScalar matrix[20];
+            getBrightnessMatrix(op->amount(), matrix);
+            applyColorMatrix(&canvas, source, matrix);
+            break;
+        }
+        case FilterOperation::CONTRAST: {
+            const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+            SkScalar matrix[20];
+            getContrastMatrix(op->amount(), matrix);
+            applyColorMatrix(&canvas, source, matrix);
+            break;
+        }
         case FilterOperation::GRAYSCALE: {
             const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
             SkScalar matrix[20];
@@ -205,7 +242,7 @@
         case FilterOperation::SATURATE: {
             const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
             SkScalar matrix[20];
-            getSaturateMatrix(1 - op->amount(), matrix);
+            getSaturateMatrix(op->amount(), matrix);
             applyColorMatrix(&canvas, source, matrix);
             break;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to