Title: [125903] trunk/Source
Revision
125903
Author
commit-qu...@webkit.org
Date
2012-08-17 08:22:35 -0700 (Fri, 17 Aug 2012)

Log Message

Add support for Skia Magnifier filter to Chromium layers
https://bugs.webkit.org/show_bug.cgi?id=93939

Patch by Zach Kuznia <z...@chromium.org> on 2012-08-17
Reviewed by James Robinson.

This is used by Chrome OS for the screen magnifier

Source/Platform:

* chromium/public/WebFilterOperation.h:
(WebKit::WebFilterOperation::zoomRect):
(WebFilterOperation):
(WebKit::WebFilterOperation::createZoomFilter):
(WebKit::WebFilterOperation::WebFilterOperation):

Source/WebCore:

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

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (125902 => 125903)


--- trunk/Source/Platform/ChangeLog	2012-08-17 15:17:25 UTC (rev 125902)
+++ trunk/Source/Platform/ChangeLog	2012-08-17 15:22:35 UTC (rev 125903)
@@ -1,3 +1,18 @@
+2012-08-17  Zach Kuznia  <z...@chromium.org>
+
+        Add support for Skia Magnifier filter to Chromium layers
+        https://bugs.webkit.org/show_bug.cgi?id=93939
+
+        Reviewed by James Robinson.
+
+        This is used by Chrome OS for the screen magnifier
+
+        * chromium/public/WebFilterOperation.h:
+        (WebKit::WebFilterOperation::zoomRect):
+        (WebFilterOperation):
+        (WebKit::WebFilterOperation::createZoomFilter):
+        (WebKit::WebFilterOperation::WebFilterOperation):
+
 2012-08-16  James Robinson  <jam...@chromium.org>
 
         [chromium] Remove unnecessary tree hierarchy inspection APIs from WebLayer

Modified: trunk/Source/Platform/chromium/public/WebFilterOperation.h (125902 => 125903)


--- trunk/Source/Platform/chromium/public/WebFilterOperation.h	2012-08-17 15:17:25 UTC (rev 125902)
+++ trunk/Source/Platform/chromium/public/WebFilterOperation.h	2012-08-17 15:22:35 UTC (rev 125903)
@@ -30,6 +30,7 @@
 #include "WebCommon.h"
 #include "WebColor.h"
 #include "WebPoint.h"
+#include "WebRect.h"
 
 namespace WebKit {
 
@@ -47,6 +48,7 @@
         FilterTypeBlur,
         FilterTypeDropShadow,
         FilterTypeColorMatrix,
+        FilterTypeZoom,
     };
 
     FilterType type() const { return m_type; }
@@ -70,6 +72,12 @@
         return m_matrix;
     }
 
+    WebRect zoomRect() const
+    {
+        WEBKIT_ASSERT(m_type == FilterTypeZoom);
+        return WebRect(m_zoomRect);
+    }
+
 #define WEBKIT_HAS_NEW_WEBFILTEROPERATION_API 1
     static WebFilterOperation createGrayscaleFilter(float amount) { return WebFilterOperation(FilterTypeGrayscale, amount); }
     static WebFilterOperation createSepiaFilter(float amount) { return WebFilterOperation(FilterTypeSepia, amount); }
@@ -82,6 +90,7 @@
     static WebFilterOperation createBlurFilter(float amount) { return WebFilterOperation(FilterTypeBlur, amount); }
     static WebFilterOperation createDropShadowFilter(WebPoint offset, float stdDeviation, WebColor color) { return WebFilterOperation(FilterTypeDropShadow, offset, stdDeviation, color); }
     static WebFilterOperation createColorMatrixFilter(SkScalar matrix[20]) { return WebFilterOperation(FilterTypeColorMatrix, matrix); }
+    static WebFilterOperation createZoomFilter(WebRect rect, int inset) { return WebFilterOperation(FilterTypeZoom, rect, inset); }
 
     bool equals(const WebFilterOperation& other) const;
 
@@ -92,6 +101,7 @@
     WebPoint m_dropShadowOffset;
     WebColor m_dropShadowColor;
     SkScalar m_matrix[20];
+    WebRect m_zoomRect;
 
     WebFilterOperation(FilterType type, float amount)
     {
@@ -111,6 +121,14 @@
     }
 
     WebFilterOperation(FilterType, SkScalar matrix[20]);
+
+    WebFilterOperation(FilterType type, WebRect rect, float inset)
+    {
+        WEBKIT_ASSERT(type == FilterTypeZoom);
+        m_type = type;
+        m_amount = inset;
+        m_zoomRect = rect;
+    }
 };
 
 inline bool operator==(const WebFilterOperation& a, const WebFilterOperation& b)

Modified: trunk/Source/WebCore/ChangeLog (125902 => 125903)


--- trunk/Source/WebCore/ChangeLog	2012-08-17 15:17:25 UTC (rev 125902)
+++ trunk/Source/WebCore/ChangeLog	2012-08-17 15:22:35 UTC (rev 125903)
@@ -1,3 +1,16 @@
+2012-08-17  Zach Kuznia  <z...@chromium.org>
+
+        Add support for Skia Magnifier filter to Chromium layers
+        https://bugs.webkit.org/show_bug.cgi?id=93939
+
+        Reviewed by James Robinson.
+
+        This is used by Chrome OS for the screen magnifier
+
+        * platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp:
+        (WebCore::CCRenderSurfaceFilters::optimize):
+        (WebCore::CCRenderSurfaceFilters::apply):
+
 2012-08-17  Allan Sandfeld Jensen  <allan.jen...@nokia.com>
 
         Touch adjustment for context menu gestures

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp	2012-08-17 15:17:25 UTC (rev 125902)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp	2012-08-17 15:22:35 UTC (rev 125903)
@@ -35,6 +35,7 @@
 #include "SkColorMatrixFilter.h"
 #include "SkGpuDevice.h"
 #include "SkGrTexturePixelRef.h"
+#include "SkMagnifierImageFilter.h"
 #include <public/WebFilterOperation.h>
 #include <public/WebFilterOperations.h>
 #include <public/WebGraphicsContext3D.h>
@@ -366,6 +367,7 @@
         switch (op.type()) {
         case WebKit::WebFilterOperation::FilterTypeBlur:
         case WebKit::WebFilterOperation::FilterTypeDropShadow:
+        case WebKit::WebFilterOperation::FilterTypeZoom:
             newList.append(op);
             break;
         case WebKit::WebFilterOperation::FilterTypeBrightness:
@@ -426,6 +428,20 @@
             canvas->drawBitmap(state.source(), 0, 0);
             break;
         }
+        case WebKit::WebFilterOperation::FilterTypeZoom: {
+            SkPaint paint;
+            SkAutoTUnref<SkImageFilter> zoomFilter(
+                new SkMagnifierImageFilter(
+                    SkRect::MakeXYWH(op.zoomRect().x,
+                                     op.zoomRect().y,
+                                     op.zoomRect().width,
+                                     op.zoomRect().height),
+                    op.amount()));
+            paint.setImageFilter(zoomFilter.get());
+            canvas->saveLayer(0, &paint);
+            canvas->drawBitmap(state.source(), 0, 0);
+            break;
+        }
         case WebKit::WebFilterOperation::FilterTypeBrightness:
         case WebKit::WebFilterOperation::FilterTypeContrast:
         case WebKit::WebFilterOperation::FilterTypeGrayscale:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to