Remote Layer Tree: Support hardware accelerated filters
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2013 19:25:09 +0000 (19:25 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2013 19:25:09 +0000 (19:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123139

Reviewed by Anders Carlsson.

* Shared/WebCoreArgumentCoders.cpp:
(CoreIPC::ArgumentCoder<Length>::encode):
(CoreIPC::ArgumentCoder<Length>::decode):
Add simple coders for Length.

(CoreIPC::encodeFilterOperation):
(CoreIPC::decodeFilterOperation):
Serialize and deserialize FilterOperations, except for CUSTOM and VALIDATED_CUSTOM.

(CoreIPC::ArgumentCoder<Length>::encode):
(CoreIPC::ArgumentCoder<Length>::decode):
Add coders for FilterOperations that delegate to {en,de}codeFilterOperation
for each operation in the list.

* Shared/WebCoreArgumentCoders.h:
Drive-by fix indentation.
Expose the Length and FilterOperations coders.

* Shared/mac/RemoteLayerTreeTransaction.h:
Add FiltersChanged and LayerProperties::filters.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
Encode and decode our FilterOperations.

(WebKit::dumpChangedLayers):
Dump information about the layers' filters.

* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::commit):
Use PlatformCAFilters code to apply a FilterOperations object to our CALayer.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::setFilters):
Replace existing filters with our new set, and note that they've changed.

(PlatformCALayerRemote::copyFiltersFrom):
Not yet implemented. Not critical for this feature, either.

(PlatformCALayerRemote::filtersCanBeComposited):
For now, this is the same as the Mac version.

* WebCore.exp.in:
Export a variety of filter-related things.

* platform/graphics/ca/PlatformCAFilters.h:
* platform/graphics/ca/mac/PlatformCAFiltersMac.mm:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayerMac::setFilters):
* platform/graphics/ca/win/PlatformCAFiltersWin.cpp:
(PlatformCAFilters::setFiltersOnLayer):
setFiltersOnLayer should take a PlatformLayer instead of a PlatformCALayer
as its argument, because it doesn't need a PlatformCALayer, and this way
we can share code with the RemoteLayerTreeHost, which only has PlatformLayers
and not PlatformCALayers.

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/ca/PlatformCAFilters.h
Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/platform/graphics/ca/win/PlatformCAFiltersWin.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

index 5b6e8c9..cf98980 100644 (file)
@@ -1,3 +1,24 @@
+2013-10-22  Tim Horton  <timothy_horton@apple.com>
+
+        Remote Layer Tree: Support hardware accelerated filters
+        https://bugs.webkit.org/show_bug.cgi?id=123139
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in:
+        Export a variety of filter-related things.
+
+        * platform/graphics/ca/PlatformCAFilters.h:
+        * platform/graphics/ca/mac/PlatformCAFiltersMac.mm:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayerMac::setFilters):
+        * platform/graphics/ca/win/PlatformCAFiltersWin.cpp:
+        (PlatformCAFilters::setFiltersOnLayer):
+        setFiltersOnLayer should take a PlatformLayer instead of a PlatformCALayer
+        as its argument, because it doesn't need a PlatformCALayer, and this way
+        we can share code with the RemoteLayerTreeHost, which only has PlatformLayers
+        and not PlatformCALayers.
+
 2013-10-22  Brendan Long  <b.long@cablelabs.com>
 
         cue.text fails for some track element cues
index c411dd7..ff0869d 100644 (file)
@@ -603,6 +603,7 @@ __ZN7WebCore16DatabaseStrategy23createIDBFactoryBackendEv
 __ZN7WebCore16DeviceMotionData12Acceleration6createEbdbdbd
 __ZN7WebCore16DeviceMotionData12RotationRate6createEbdbdbd
 __ZN7WebCore16DeviceMotionData6createEN3WTF10PassRefPtrINS0_12AccelerationEEES4_NS2_INS0_12RotationRateEEEbd
+__ZN7WebCore16FilterOperationsC1Ev
 __ZN7WebCore16FontPlatformDataD1Ev
 __ZN7WebCore16FrameLoadRequestC1EPNS_5FrameERKNS_15ResourceRequestERKNS_14SubstituteDataE
 __ZN7WebCore16HTMLInputElement13setAutofilledEb
@@ -673,6 +674,7 @@ __ZN7WebCore17HistoryController33restoreScrollPositionAndViewStateEv
 __ZN7WebCore17JSDOMGlobalObject6s_infoE
 __ZN7WebCore17MouseRelatedEvent7offsetXEv
 __ZN7WebCore17MouseRelatedEvent7offsetYEv
+__ZN7WebCore17PlatformCAFilters17setFiltersOnLayerEP7CALayerRKNS_16FilterOperationsE
 __ZN7WebCore17RegularExpressionC1ERKN3WTF6StringENS1_19TextCaseSensitivityENS_13MultilineModeE
 __ZN7WebCore17RegularExpressionD1Ev
 __ZN7WebCore17SQLiteTransaction5beginEv
@@ -689,6 +691,7 @@ __ZN7WebCore17setCookiesFromDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_RKN3WT
 __ZN7WebCore17userVisibleStringEP5NSURL
 __ZN7WebCore18DOMWindowExtensionC1EPNS_5FrameERNS_15DOMWrapperWorldE
 __ZN7WebCore18PlatformCALayerMac18setGeometryFlippedEb
+__ZN7WebCore18PlatformCALayerMac22filtersCanBeCompositedERKNS_16FilterOperationsE
 __ZN7WebCore18PlatformPasteboard10uniqueNameEv
 __ZN7WebCore18PlatformPasteboard13bufferForTypeERKN3WTF6StringE
 __ZN7WebCore18PlatformPasteboard13stringForTypeERKN3WTF6StringE
@@ -853,6 +856,7 @@ __ZN7WebCore24FrameDestructionObserver14frameDestroyedEv
 __ZN7WebCore24FrameDestructionObserver14willDetachPageEv
 __ZN7WebCore24FrameDestructionObserverC2EPNS_5FrameE
 __ZN7WebCore24FrameDestructionObserverD2Ev
+__ZN7WebCore24ReferenceFilterOperationC1ERKN3WTF6StringES4_NS_15FilterOperation13OperationTypeE
 __ZN7WebCore24createFragmentFromMarkupERNS_8DocumentERKN3WTF6StringES5_NS_19ParserContentPolicyE
 __ZN7WebCore24decodeURLEscapeSequencesERKN3WTF6StringE
 __ZN7WebCore24deleteCookiesForHostnameERKNS_21NetworkStorageSessionERKN3WTF6StringE
@@ -1715,6 +1719,7 @@ __ZNK7WebCore6Editor7canEditEv
 __ZNK7WebCore6Editor8canPasteEv
 __ZNK7WebCore6Editor9canDeleteEv
 __ZNK7WebCore6Length22decrementCalculatedRefEv
+__ZNK7WebCore6Length22incrementCalculatedRefEv
 __ZNK7WebCore6Region5rectsEv
 __ZNK7WebCore6Region8containsERKS0_
 __ZNK7WebCore6Region9totalAreaEv
@@ -1808,7 +1813,11 @@ __ZTVN7WebCore15StorageStrategyE
 __ZTVN7WebCore16DatabaseStrategyE
 __ZTVN7WebCore16IconDatabaseBaseE
 __ZTVN7WebCore17FrameLoaderClientE
+__ZTVN7WebCore19BlurFilterOperationE
+__ZTVN7WebCore25DropShadowFilterOperationE
 __ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
+__ZTVN7WebCore31BasicColorMatrixFilterOperationE
+__ZTVN7WebCore37BasicComponentTransferFilterOperationE
 __ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsERNS_15GraphicsContextERKNS_7IntRectE
 __ZThn???_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
 __ZThn???_N7WebCore15GraphicsLayerCA32platformCALayerDeviceScaleFactorEv
index 0e92a69..aa94c28 100644 (file)
                2D5A5931152525D00036EE51 /* ImageOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = A8748D6612CC3763001FBA41 /* ImageOrientation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D5BC42716F882EE007048D0 /* SecurityPolicyViolationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5BC42516F882BE007048D0 /* SecurityPolicyViolationEvent.h */; };
                2D6E468417D660F500ECF8BB /* PDFDocumentImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */; };
-               2D70BA1318074DDF0001908A /* PlatformCALayerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D70BA1218074DDF0001908A /* PlatformCALayerMac.h */; };
+               2D70BA1318074DDF0001908A /* PlatformCALayerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D70BA1218074DDF0001908A /* PlatformCALayerMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D70BA1518074F860001908A /* PlatformCALayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D70BA1418074F850001908A /* PlatformCALayer.cpp */; };
                2D8287F616E4A0380086BD00 /* HitTestLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */; };
                2D8287F716E4A0380086BD00 /* HitTestLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8287F516E4A0380086BD00 /* HitTestLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
index 68a3edb..29ccef4 100644 (file)
@@ -30,6 +30,7 @@
 #if ENABLE(CSS_FILTERS)
 
 #include "FilterOperations.h"
+#include "PlatformLayer.h"
 #include <wtf/RetainPtr.h>
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 OBJC_CLASS NSValue;
 
 namespace WebCore {
-class PlatformCALayer;
 
 class PlatformCAFilters {
 public:
-    static void setFiltersOnLayer(PlatformCALayer*, const FilterOperations&);
+    static void setFiltersOnLayer(PlatformLayer*, const FilterOperations&);
     static int numAnimatedFilterProperties(FilterOperation::OperationType);
     static const char* animatedFilterPropertyName(FilterOperation::OperationType, int internalFilterPropertyIndex);
 
index bc3f650..a9172d2 100644 (file)
@@ -81,10 +81,8 @@ static double sepiaNoneConstants[3][3] = {
     { 0, 0, 1 }
 };
 
-void PlatformCAFilters::setFiltersOnLayer(PlatformCALayer* platformCALayer, const FilterOperations& filters)
+void PlatformCAFilters::setFiltersOnLayer(PlatformLayer* layer, const FilterOperations& filters)
 {
-    CALayer* layer = platformCALayer->platformLayer();
-
     if (!filters.size()) {
         BEGIN_BLOCK_OBJC_EXCEPTIONS
         [layer setFilters:nil];
index e694fd8..05cdb12 100644 (file)
@@ -633,7 +633,7 @@ void PlatformCALayerMac::setOpacity(float value)
 #if ENABLE(CSS_FILTERS)
 void PlatformCALayerMac::setFilters(const FilterOperations& filters)
 {
-    PlatformCAFilters::setFiltersOnLayer(this, filters);
+    PlatformCAFilters::setFiltersOnLayer(this->platformLayer(), filters);
 }
 
 void PlatformCALayerMac::copyFiltersFrom(const PlatformCALayer* sourceLayer)
index 3eb3954..30c40a7 100644 (file)
@@ -32,7 +32,7 @@
 
 using namespace WebCore;
 
-void PlatformCAFilters::setFiltersOnLayer(PlatformCALayer* platformCALayer, const FilterOperations& filters)
+void PlatformCAFilters::setFiltersOnLayer(PlatformLayer* layer, const FilterOperations& filters)
 {
     // Hardware filter animation not implemented on Windows.
 }
index ed31cff..06c2e26 100644 (file)
@@ -1,3 +1,53 @@
+2013-10-22  Tim Horton  <timothy_horton@apple.com>
+
+        Remote Layer Tree: Support hardware accelerated filters
+        https://bugs.webkit.org/show_bug.cgi?id=123139
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (CoreIPC::ArgumentCoder<Length>::encode):
+        (CoreIPC::ArgumentCoder<Length>::decode):
+        Add simple coders for Length.
+
+        (CoreIPC::encodeFilterOperation):
+        (CoreIPC::decodeFilterOperation):
+        Serialize and deserialize FilterOperations, except for CUSTOM and VALIDATED_CUSTOM.
+
+        (CoreIPC::ArgumentCoder<Length>::encode):
+        (CoreIPC::ArgumentCoder<Length>::decode):
+        Add coders for FilterOperations that delegate to {en,de}codeFilterOperation
+        for each operation in the list.
+
+        * Shared/WebCoreArgumentCoders.h:
+        Drive-by fix indentation.
+        Expose the Length and FilterOperations coders.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        Add FiltersChanged and LayerProperties::filters.
+
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        Encode and decode our FilterOperations.
+
+        (WebKit::dumpChangedLayers):
+        Dump information about the layers' filters.
+
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::commit):
+        Use PlatformCAFilters code to apply a FilterOperations object to our CALayer.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::setFilters):
+        Replace existing filters with our new set, and note that they've changed.
+
+        (PlatformCALayerRemote::copyFiltersFrom):
+        Not yet implemented. Not critical for this feature, either.
+
+        (PlatformCALayerRemote::filtersCanBeComposited):
+        For now, this is the same as the Mac version.
+
 2013-10-22  Brian Holt  <brian.holt@samsung.com>
 
         [GTK] Add WebKit2 API for TLS errors
index d8b8950..d9960b9 100644 (file)
@@ -37,6 +37,8 @@
 #include <WebCore/DragSession.h>
 #include <WebCore/Editor.h>
 #include <WebCore/FileChooser.h>
+#include <WebCore/FilterOperation.h>
+#include <WebCore/FilterOperations.h>
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/GraphicsLayer.h>
 #include <WebCore/Image.h>
@@ -158,6 +160,17 @@ bool ArgumentCoder<IntSize>::decode(ArgumentDecoder& decoder, IntSize& intSize)
 }
 
 
+void ArgumentCoder<Length>::encode(ArgumentEncoder& encoder, const Length& length)
+{
+    SimpleArgumentCoder<Length>::encode(encoder, length);
+}
+
+bool ArgumentCoder<Length>::decode(ArgumentDecoder& decoder, Length& length)
+{
+    return SimpleArgumentCoder<Length>::decode(decoder, length);
+}
+
+
 void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes)
 {
     SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
@@ -1167,4 +1180,145 @@ bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder& decoder, WebCor
     return true;
 }
 
+static void encodeFilterOperation(ArgumentEncoder& encoder, const FilterOperation& filter)
+{
+    encoder.encodeEnum(filter.getOperationType());
+
+    switch (filter.getOperationType()) {
+    case FilterOperation::REFERENCE: {
+        const auto& referenceFilter = static_cast<const ReferenceFilterOperation&>(filter);
+        encoder << referenceFilter.url();
+        encoder << referenceFilter.fragment();
+        break;
+    }
+    case FilterOperation::GRAYSCALE:
+    case FilterOperation::SEPIA:
+    case FilterOperation::SATURATE:
+    case FilterOperation::HUE_ROTATE:
+        encoder << static_cast<const BasicColorMatrixFilterOperation&>(filter).amount();
+        break;
+    case FilterOperation::INVERT:
+    case FilterOperation::OPACITY:
+    case FilterOperation::BRIGHTNESS:
+    case FilterOperation::CONTRAST:
+        encoder << static_cast<const BasicComponentTransferFilterOperation&>(filter).amount();
+        break;
+    case FilterOperation::BLUR:
+        encoder << static_cast<const BlurFilterOperation&>(filter).stdDeviation();
+        break;
+    case FilterOperation::DROP_SHADOW: {
+        const auto& dropShadowFilter = static_cast<const DropShadowFilterOperation&>(filter);
+        encoder << dropShadowFilter.location();
+        encoder << dropShadowFilter.stdDeviation();
+        encoder << dropShadowFilter.color();
+        break;
+    }
+#if ENABLE(CSS_SHADERS)
+    case FilterOperation::CUSTOM:
+    case FilterOperation::VALIDATED_CUSTOM:
+        ASSERT_NOT_REACHED();
+        break;
+#endif
+    case FilterOperation::PASSTHROUGH:
+    case FilterOperation::NONE:
+        break;
+    };
+}
+
+static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperation>& filter)
+{
+    FilterOperation::OperationType type;
+    if (!decoder.decodeEnum(type))
+        return false;
+
+    switch (type) {
+    case FilterOperation::REFERENCE: {
+        String url;
+        String fragment;
+        if (!decoder.decode(url))
+            return false;
+        if (!decoder.decode(fragment))
+            return false;
+        filter = ReferenceFilterOperation::create(url, fragment, type);
+        break;
+    }
+    case FilterOperation::GRAYSCALE:
+    case FilterOperation::SEPIA:
+    case FilterOperation::SATURATE:
+    case FilterOperation::HUE_ROTATE: {
+        double amount;
+        if (!decoder.decode(amount))
+            return false;
+        filter = BasicColorMatrixFilterOperation::create(amount, type);
+        break;
+    }
+    case FilterOperation::INVERT:
+    case FilterOperation::OPACITY:
+    case FilterOperation::BRIGHTNESS:
+    case FilterOperation::CONTRAST: {
+        double amount;
+        if (!decoder.decode(amount))
+            return false;
+        filter = BasicComponentTransferFilterOperation::create(amount, type);
+        break;
+    }
+    case FilterOperation::BLUR: {
+        Length stdDeviation;
+        if (!decoder.decode(stdDeviation))
+            return false;
+        filter = BlurFilterOperation::create(stdDeviation, type);
+        break;
+    }
+    case FilterOperation::DROP_SHADOW: {
+        IntPoint location;
+        int stdDeviation;
+        Color color;
+        if (!decoder.decode(location))
+            return false;
+        if (!decoder.decode(stdDeviation))
+            return false;
+        if (!decoder.decode(color))
+            return false;
+        filter = DropShadowFilterOperation::create(location, stdDeviation, color, type);
+        break;
+    }
+#if ENABLE(CSS_SHADERS)
+    case FilterOperation::CUSTOM:
+    case FilterOperation::VALIDATED_CUSTOM:
+        ASSERT_NOT_REACHED();
+        break;
+#endif
+    case FilterOperation::PASSTHROUGH:
+    case FilterOperation::NONE:
+        break;
+    };
+
+    return true;
+}
+
+
+void ArgumentCoder<FilterOperations>::encode(ArgumentEncoder& encoder, const FilterOperations& filters)
+{
+    encoder << static_cast<uint64_t>(filters.size());
+
+    for (const auto& filter : filters.operations())
+        encodeFilterOperation(encoder, *filter);
+}
+
+bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOperations& filters)
+{
+    uint64_t filterCount;
+    if (!decoder.decode(filterCount))
+        return false;
+
+    for (uint64_t i = 0; i < filterCount; ++i) {
+        RefPtr<FilterOperation> filter;
+        if (!decodeFilterOperation(decoder, filter))
+            return false;
+        filters.operations().append(std::move(filter));
+    }
+
+    return true;
+}
+
 } // namespace CoreIPC
index b93ee81..6771a29 100644 (file)
 #include "ArgumentCoders.h"
 
 namespace WebCore {
-    class AffineTransform;
-    class AuthenticationChallenge;
-    class Color;
-    class Credential;
-    class Cursor;
-    class DatabaseDetails;
-    class FloatPoint;
-    class FloatPoint3D;
-    class FloatRect;
-    class FloatSize;
-    class HTTPHeaderMap;
-    class IntPoint;
-    class IntRect;
-    class IntSize;
-    class KeyframeValueList;
-    class URL;
-    class Notification;
-    class CertificateInfo;
-    class ProtectionSpace;
-    class ResourceError;
-    class ResourceRequest;
-    class ResourceResponse;
-    class TextCheckingRequestData;
-    class TransformationMatrix;
-    class UserStyleSheet;
-    class UserScript;
-    struct CompositionUnderline;
-    struct Cookie;
-    struct DictationAlternative;
-    struct DragSession;
-    struct FileChooserSettings;
-    struct GrammarDetail;
-    struct MimeClassInfo;
-    struct PasteboardImage;
-    struct PasteboardWebContent;
-    struct PluginInfo;
-    struct TextCheckingResult;
-    struct ViewportAttributes;
-    struct WindowFeatures;
+class AffineTransform;
+class AuthenticationChallenge;
+class Color;
+class Credential;
+class Cursor;
+class DatabaseDetails;
+class FilterOperations;
+class FloatPoint;
+class FloatPoint3D;
+class FloatRect;
+class FloatSize;
+class HTTPHeaderMap;
+class IntPoint;
+class IntRect;
+class IntSize;
+class KeyframeValueList;
+class URL;
+class Notification;
+class CertificateInfo;
+class ProtectionSpace;
+class ResourceError;
+class ResourceRequest;
+class ResourceResponse;
+class TextCheckingRequestData;
+class TransformationMatrix;
+class UserStyleSheet;
+class UserScript;
+struct CompositionUnderline;
+struct Cookie;
+struct DictationAlternative;
+struct DragSession;
+struct FileChooserSettings;
+struct Length;
+struct GrammarDetail;
+struct MimeClassInfo;
+struct PasteboardImage;
+struct PasteboardWebContent;
+struct PluginInfo;
+struct TextCheckingResult;
+struct ViewportAttributes;
+struct WindowFeatures;
 }
 
 #if PLATFORM(MAC)
 namespace WebCore {
-    struct KeypressCommand;
+struct KeypressCommand;
 }
 #endif
 
@@ -123,6 +125,11 @@ template<> struct ArgumentCoder<WebCore::IntSize> {
     static bool decode(ArgumentDecoder&, WebCore::IntSize&);
 };
 
+template<> struct ArgumentCoder<WebCore::Length> {
+    static void encode(ArgumentEncoder&, const WebCore::Length&);
+    static bool decode(ArgumentDecoder&, WebCore::Length&);
+};
+
 template<> struct ArgumentCoder<WebCore::ViewportAttributes> {
     static void encode(ArgumentEncoder&, const WebCore::ViewportAttributes&);
     static bool decode(ArgumentDecoder&, WebCore::ViewportAttributes&);
@@ -292,6 +299,12 @@ template<> struct ArgumentCoder<WebCore::UserScript> {
     static bool decode(ArgumentDecoder&, WebCore::UserScript&);
 };
 
+template<> struct ArgumentCoder<WebCore::FilterOperations> {
+    static void encode(ArgumentEncoder&, const WebCore::FilterOperations&);
+    static bool decode(ArgumentDecoder&, WebCore::FilterOperations&);
+};
+
+
 } // namespace CoreIPC
 
 #endif // WebCoreArgumentCoders_h
index 2b22550..861bbea 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "RemoteLayerBackingStore.h"
 #include <WebCore/Color.h>
+#include <WebCore/FilterOperations.h>
 #include <WebCore/FloatPoint3D.h>
 #include <WebCore/FloatSize.h>
 #include <WebCore/PlatformCALayer.h>
@@ -73,7 +74,8 @@ public:
         MagnificationFilterChanged = 1 << 21,
         SpeedChanged = 1 << 22,
         TimeOffsetChanged = 1 << 23,
-        BackingStoreChanged = 1 << 24
+        BackingStoreChanged = 1 << 24,
+        FiltersChanged = 1 << 25
     };
 
     struct LayerCreationProperties {
@@ -120,6 +122,7 @@ public:
         float speed;
         double timeOffset;
         RemoteLayerBackingStore backingStore;
+        WebCore::FilterOperations filters;
     };
 
     explicit RemoteLayerTreeTransaction();
index dbbd686..625b3ba 100644 (file)
@@ -140,6 +140,9 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(CoreIPC::ArgumentEncode
 
     if (changedProperties & BackingStoreChanged)
         encoder << backingStore;
+
+    if (changedProperties & FiltersChanged)
+        encoder << filters;
 }
 
 bool RemoteLayerTreeTransaction::LayerProperties::decode(CoreIPC::ArgumentDecoder& decoder, LayerProperties& result)
@@ -272,6 +275,11 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(CoreIPC::ArgumentDecode
             return false;
     }
 
+    if (result.changedProperties & FiltersChanged) {
+        if (!decoder.decode(result.filters))
+            return false;
+    }
+
     return true;
 }
 
@@ -355,6 +363,7 @@ public:
     RemoteLayerTreeTextStream& operator<<(FloatSize);
     RemoteLayerTreeTextStream& operator<<(FloatRect);
     RemoteLayerTreeTextStream& operator<<(const Vector<RemoteLayerTreeTransaction::LayerID>& layers);
+    RemoteLayerTreeTextStream& operator<<(const FilterOperations&);
 
     void increaseIndent() { ++m_indent; }
     void decreaseIndent() { --m_indent; ASSERT(m_indent >= 0); }
@@ -402,6 +411,67 @@ RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer
     return ts;
 }
 
+RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FilterOperations& filters)
+{
+    RemoteLayerTreeTextStream& ts = *this;
+    for (size_t i = 0; i < filters.size(); ++i) {
+        const auto filter = filters.at(i);
+        switch (filter->getOperationType()) {
+        case FilterOperation::REFERENCE:
+            ts << "reference";
+            break;
+        case FilterOperation::GRAYSCALE:
+            ts << "grayscale";
+            break;
+        case FilterOperation::SEPIA:
+            ts << "sepia";
+            break;
+        case FilterOperation::SATURATE:
+            ts << "saturate";
+            break;
+        case FilterOperation::HUE_ROTATE:
+            ts << "hue rotate";
+            break;
+        case FilterOperation::INVERT:
+            ts << "invert";
+            break;
+        case FilterOperation::OPACITY:
+            ts << "opacity";
+            break;
+        case FilterOperation::BRIGHTNESS:
+            ts << "brightness";
+            break;
+        case FilterOperation::CONTRAST:
+            ts << "contrast";
+            break;
+        case FilterOperation::BLUR:
+            ts << "blur";
+            break;
+        case FilterOperation::DROP_SHADOW:
+            ts << "drop shadow";
+            break;
+#if ENABLE(CSS_SHADERS)
+        case FilterOperation::CUSTOM:
+            ts << "custom";
+            break;
+        case FilterOperation::VALIDATED_CUSTOM:
+            ts << "custom (validated)";
+            break;
+#endif
+        case FilterOperation::PASSTHROUGH:
+            ts << "passthrough";
+            break;
+        case FilterOperation::NONE:
+            ts << "none";
+            break;
+        }
+
+        if (i < filters.size() - 1)
+            ts << " ";
+    }
+    return ts;
+}
+
 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatPoint3D point)
 {
     RemoteLayerTreeTextStream& ts = *this;
@@ -554,6 +624,9 @@ static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const HashMap<Remot
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged)
             dumpProperty<ShareableBitmap*>(ts, "backingStore", layerProperties.backingStore.bitmap());
 
+        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
+            dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters);
+
         ts << ")";
 
         ts.decreaseIndent();
index 14d5029..814dbec 100644 (file)
@@ -31,6 +31,7 @@
 #import "ShareableBitmap.h"
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
+#import <WebCore/PlatformCAFilters.h>
 #import <WebCore/PlatformLayer.h>
 
 #import <QuartzCore/QuartzCore.h>
@@ -203,6 +204,9 @@ void RemoteLayerTreeHost::commit(const RemoteLayerTreeTransaction& transaction)
             RetainPtr<CGImageRef> image = properties.backingStore.bitmap()->makeCGImageCopy();
             layer.contents = (id)image.get();
         }
+
+        if (properties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
+            PlatformCAFilters::setFiltersOnLayer(layer, properties.filters);
     }
 
     for (auto destroyedLayer : transaction.destroyedLayers())
index 3afbd55..1e7daf9 100644 (file)
@@ -36,6 +36,7 @@
 #import <WebCore/GraphicsLayerCA.h>
 #import <WebCore/LengthFunctions.h>
 #import <WebCore/PlatformCAFilters.h>
+#import <WebCore/PlatformCALayerMac.h>
 #import <WebCore/TiledBacking.h>
 #import <wtf/CurrentTime.h>
 #import <wtf/RetainPtr.h>
@@ -375,15 +376,18 @@ void PlatformCALayerRemote::setOpacity(float value)
 #if ENABLE(CSS_FILTERS)
 void PlatformCALayerRemote::setFilters(const FilterOperations& filters)
 {
+    m_properties.filters = filters;
+    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
 }
 
 void PlatformCALayerRemote::copyFiltersFrom(const PlatformCALayer* sourceLayer)
 {
+    ASSERT_NOT_REACHED();
 }
 
 bool PlatformCALayerRemote::filtersCanBeComposited(const FilterOperations& filters)
 {
-    return false; // This will probably work the same as Mac eventually?
+    return PlatformCALayerMac::filtersCanBeComposited(filters);
 }
 #endif