[Win][Direct2D] Disable some CoreGraphics and CoreAnimation-based logic when building...
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2016 21:16:27 +0000 (21:16 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2016 21:16:27 +0000 (21:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162977

Reviewed by Alex Christensen.

Currently the Direct2D implementation does not support some of the accelerated compositing
features that require CoreAnimation. During this bring-up, we want to disable these routines
so that we can build and run in (mostly) unaccelerated drawing.

This patch mostly consists of adding "#if USE(CG)" and "#if USE(CA)" to files that are
specific to those implementations.

This change should have no impact on non-Direct2D ports.

No change in behavior for active ports.

* config.h: Turn of CG when building in Direct2D.
* css/CSSFontFaceSource.cpp:
* loader/cache/CachedFont.cpp:
* loader/cache/CachedSVGFont.cpp:
* page/CaptionUserPreferencesMediaAF.cpp:
* page/win/FrameCGWin.cpp:
* page/win/FrameDirect2D.cpp: Added.
* platform/graphics/Font.cpp:
* platform/graphics/FontCache.cpp:
* platform/graphics/FontPlatformData.cpp:
* platform/graphics/GraphicsContext.h:
* platform/graphics/Image.cpp:
* platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
* platform/graphics/ca/GraphicsLayerCA.cpp:
* platform/graphics/ca/PlatformCALayer.cpp:
* platform/graphics/ca/TileController.cpp:
* platform/graphics/ca/TileGrid.cpp:
* platform/graphics/ca/TileGrid.h:
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
* platform/graphics/ca/win/LayerChangesFlusher.cpp:
* platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
* platform/graphics/ca/win/PlatformCAAnimationWin.h:
* platform/graphics/ca/win/PlatformCAFiltersWin.cpp:
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
* platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
* platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp:
* platform/graphics/ca/win/WebTiledBackingLayerWin.cpp:
* platform/graphics/cg/GradientCG.cpp:
* platform/graphics/cg/GraphicsContextCG.cpp:
* platform/graphics/cg/ImageBufferCG.cpp:
* platform/graphics/cg/ImageBufferDataCG.cpp:
* platform/graphics/cg/PDFDocumentImage.cpp:
* platform/graphics/cg/PatternCG.cpp:
* platform/graphics/cg/SubimageCacheWithTimer.cpp:
* platform/graphics/win/FontCGWin.cpp:
* platform/graphics/win/FontPlatformDataCGWin.cpp:
* platform/graphics/win/GlyphPageTreeNodeCGWin.cpp:
* platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp:
* platform/graphics/win/GradientDirect2D.cpp:
* platform/graphics/win/PathDirect2D.cpp: Fix a few build problems I didn't notice
while building without Direct2D active.
* platform/graphics/win/SimpleFontDataCGWin.cpp:
* platform/graphics/win/SimpleFontDataWin.cpp:
* platform/win/DragImageCGWin.cpp:
* platform/win/DragImageDirect2D.cpp: Added.
* rendering/RenderMediaControls.cpp:

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

47 files changed:
Source/WebCore/ChangeLog
Source/WebCore/config.h
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/loader/cache/CachedFont.cpp
Source/WebCore/loader/cache/CachedSVGFont.cpp
Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
Source/WebCore/page/win/FrameCGWin.cpp
Source/WebCore/page/win/FrameWinDirect2D.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/FontCache.cpp
Source/WebCore/platform/graphics/FontPlatformData.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp
Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp
Source/WebCore/platform/graphics/ca/TileController.cpp
Source/WebCore/platform/graphics/ca/TileGrid.cpp
Source/WebCore/platform/graphics/ca/TileGrid.h
Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.h
Source/WebCore/platform/graphics/ca/win/PlatformCAFiltersWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp
Source/WebCore/platform/graphics/cg/GradientCG.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
Source/WebCore/platform/graphics/cg/PatternCG.cpp
Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.cpp
Source/WebCore/platform/graphics/win/FontCGWin.cpp
Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp
Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp
Source/WebCore/platform/graphics/win/GradientDirect2D.cpp
Source/WebCore/platform/graphics/win/PathDirect2D.cpp
Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
Source/WebCore/platform/win/DragImageCGWin.cpp
Source/WebCore/platform/win/DragImageDirect2D.cpp [new file with mode: 0644]
Source/WebCore/rendering/RenderMediaControls.cpp

index 68077f0..543910f 100644 (file)
@@ -1,3 +1,69 @@
+2016-10-05  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win][Direct2D] Disable some CoreGraphics and CoreAnimation-based logic when building for D2D
+        https://bugs.webkit.org/show_bug.cgi?id=162977
+
+        Reviewed by Alex Christensen.
+
+        Currently the Direct2D implementation does not support some of the accelerated compositing
+        features that require CoreAnimation. During this bring-up, we want to disable these routines
+        so that we can build and run in (mostly) unaccelerated drawing.
+
+        This patch mostly consists of adding "#if USE(CG)" and "#if USE(CA)" to files that are
+        specific to those implementations.
+
+        This change should have no impact on non-Direct2D ports.
+
+        No change in behavior for active ports.
+
+        * config.h: Turn of CG when building in Direct2D.
+        * css/CSSFontFaceSource.cpp:
+        * loader/cache/CachedFont.cpp:
+        * loader/cache/CachedSVGFont.cpp:
+        * page/CaptionUserPreferencesMediaAF.cpp:
+        * page/win/FrameCGWin.cpp:
+        * page/win/FrameDirect2D.cpp: Added.
+        * platform/graphics/Font.cpp:
+        * platform/graphics/FontCache.cpp:
+        * platform/graphics/FontPlatformData.cpp:
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/Image.cpp:
+        * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        * platform/graphics/ca/TileController.cpp:
+        * platform/graphics/ca/TileGrid.cpp:
+        * platform/graphics/ca/TileGrid.h:
+        * platform/graphics/ca/win/CACFLayerTreeHost.cpp:
+        * platform/graphics/ca/win/LayerChangesFlusher.cpp:
+        * platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
+        * platform/graphics/ca/win/PlatformCAAnimationWin.h:
+        * platform/graphics/ca/win/PlatformCAFiltersWin.cpp:
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
+        * platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp:
+        * platform/graphics/ca/win/WebTiledBackingLayerWin.cpp:
+        * platform/graphics/cg/GradientCG.cpp:
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        * platform/graphics/cg/ImageBufferDataCG.cpp:
+        * platform/graphics/cg/PDFDocumentImage.cpp:
+        * platform/graphics/cg/PatternCG.cpp:
+        * platform/graphics/cg/SubimageCacheWithTimer.cpp:
+        * platform/graphics/win/FontCGWin.cpp:
+        * platform/graphics/win/FontPlatformDataCGWin.cpp:
+        * platform/graphics/win/GlyphPageTreeNodeCGWin.cpp:
+        * platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp:
+        * platform/graphics/win/GradientDirect2D.cpp:
+        * platform/graphics/win/PathDirect2D.cpp: Fix a few build problems I didn't notice
+        while building without Direct2D active.
+        * platform/graphics/win/SimpleFontDataCGWin.cpp:
+        * platform/graphics/win/SimpleFontDataWin.cpp:
+        * platform/win/DragImageCGWin.cpp:
+        * platform/win/DragImageDirect2D.cpp: Added.
+        * rendering/RenderMediaControls.cpp:
+
 2016-10-05  Chris Dumez  <cdumez@apple.com>
 
         KeyboardEvent.getModifierState() should support "CapsLock" modifier
index 3050663..7f96c20 100644 (file)
@@ -94,6 +94,8 @@
 #ifndef _WINSOCKAPI_
 #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
 #endif
+#elif USE(DIRECT2D)
+#undef USE_CG
 #elif !USE(WINGDI)
 #define USE_CG 1
 #undef USE_CAIRO
index cca5d4b..f02c082 100644 (file)
 #include "SVGURIReference.h"
 #endif
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 namespace WebCore {
 
 inline void CSSFontFaceSource::setStatus(Status newStatus)
index e7a5d29..ea07271 100644 (file)
 #include "WOFFFileFormat.h"
 #include <wtf/Vector.h>
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 namespace WebCore {
 
 CachedFont::CachedFont(CachedResourceRequest&& request, SessionID sessionID, Type type)
index cc72785..510c0f6 100644 (file)
 #include "TypedElementDescendantIterator.h"
 #include "SVGToOTFFontConversion.h"
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 namespace WebCore {
 
 CachedSVGFont::CachedSVGFont(CachedResourceRequest&& request, SessionID sessionID)
index 70f89ad..68fdd5a 100644 (file)
@@ -27,6 +27,8 @@
 
 #if ENABLE(VIDEO_TRACK)
 
+#if !USE(DIRECT2D)
+
 #include "CaptionUserPreferencesMediaAF.h"
 
 #include "AudioTrackList.h"
@@ -965,4 +967,6 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
     
 }
 
+#endif
+
 #endif // ENABLE(VIDEO_TRACK)
index 23fca7c..336eb6d 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "FrameWin.h"
 
+#if USE(CG)
+
 #include "BitmapInfo.h"
 #include "Frame.h"
 #include "FrameSelection.h"
@@ -83,3 +85,5 @@ GDIObject<HBITMAP> imageFromRect(const Frame* frame, IntRect& ir)
 }
 
 } // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/page/win/FrameWinDirect2D.cpp b/Source/WebCore/page/win/FrameWinDirect2D.cpp
new file mode 100644 (file)
index 0000000..104b14e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "FrameWin.h"
+
+#if USE(DIRECT2D)
+
+#include "BitmapInfo.h"
+#include "Frame.h"
+#include "FrameSelection.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "RenderObject.h"
+#include "Settings.h"
+#include <d2d1.h>
+#include <windows.h>
+#include <wtf/win/GDIObject.h>
+
+namespace WebCore {
+
+GDIObject<HBITMAP> imageFromRect(const Frame* frame, IntRect& ir)
+{
+    if (!frame)
+        return nullptr;
+
+    PaintBehavior oldPaintBehavior = frame->view()->paintBehavior();
+    frame->view()->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
+
+    void* bits = nullptr;
+    auto hdc = adoptGDIObject(::CreateCompatibleDC(0));
+    int w = ir.width();
+    int h = ir.height();
+    BitmapInfo bmp = BitmapInfo::create(IntSize(w, h));
+
+    GDIObject<HBITMAP> hbmp = adoptGDIObject(::CreateDIBSection(0, &bmp, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0));
+    if (!hbmp)
+        return hbmp;
+
+    HGDIOBJ hbmpOld = SelectObject(hdc.get(), hbmp.get());
+
+    notImplemented();
+
+    SelectObject(hdc.get(), hbmpOld);
+
+    frame->view()->setPaintBehavior(oldPaintBehavior);
+
+    return hbmp;
+}
+
+} // namespace WebCore
+
+#endif
index 6d24d20..c9ac4dd 100644 (file)
 #include "OpenTypeVerticalData.h"
 #endif
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 namespace WebCore {
 
 unsigned GlyphPage::s_count = 0;
index 0a945a4..03a78e7 100644 (file)
 #include "OpenTypeVerticalData.h"
 #endif
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 #if PLATFORM(IOS)
 #include <wtf/Noncopyable.h>
 
index 1ca1649..e41902c 100644 (file)
 #include <CoreGraphics/CGFont.h>
 #endif
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 namespace WebCore {
 
 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
index c658df7..1fb6ee1 100644 (file)
@@ -579,7 +579,6 @@ private:
 
 #if USE(DIRECT2D)
     void platformInit(HDC, ID2D1RenderTarget**, RECT, bool hasAlpha = false);
-    void platformInit(ID2D1RenderTarget*);
     void drawWithoutShadow(const FloatRect& boundingRect, const std::function<void(ID2D1RenderTarget*)>&);
     void drawWithShadow(const FloatRect& boundingRect, const std::function<void(ID2D1RenderTarget*)>&);
 #endif
index d861d0c..541164a 100644 (file)
@@ -92,6 +92,9 @@ void Image::fillWithSolidColor(GraphicsContext& ctxt, const FloatRect& dstRect,
 
 void Image::drawTiled(GraphicsContext& ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode)
 {
+#if USE(DIRECT2D)
+    notImplemented();
+#else
     Color color = singlePixelSolidColor();
     if (color.isValid()) {
         fillWithSolidColor(ctxt, destRect, color, op);
@@ -199,6 +202,7 @@ void Image::drawTiled(GraphicsContext& ctxt, const FloatRect& destRect, const Fl
 #else
     startAnimation();
 #endif
+#endif
 }
 
 // FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
index 9f8a056..0b2c737 100644 (file)
@@ -54,7 +54,14 @@ CDMSessionAVFoundationCF::CDMSessionAVFoundationCF(MediaPlayerPrivateAVFoundatio
 RefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
 {
     UNUSED_PARAM(mimeType);
-
+#if USE(DIRECT2D)
+    UNUSED_PARAM(initData);
+    UNUSED_PARAM(destinationURL);
+    UNUSED_PARAM(errorCode);
+    UNUSED_PARAM(systemCode);
+    notImplemented();
+    return nullptr;
+#else
     String keyURI;
     String keyID;
     RefPtr<Uint8Array> certificate;
@@ -101,6 +108,7 @@ RefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mi
 
     RefPtr<ArrayBuffer> keyRequestBuffer = ArrayBuffer::create(CFDataGetBytePtr(keyRequest.get()), CFDataGetLength(keyRequest.get()));
     return Uint8Array::create(keyRequestBuffer, 0, keyRequestBuffer->byteLength());
+#endif
 }
 
 void CDMSessionAVFoundationCF::releaseKeys()
index 5c190dc..d5c5c15 100644 (file)
@@ -863,7 +863,11 @@ void MediaPlayerPrivateAVFoundationCF::paint(GraphicsContext& context, const Flo
         context.scale(FloatSize(1.0f, -1.0f));
         context.setImageInterpolationQuality(InterpolationLow);
         FloatRect paintRect(FloatPoint(), rect.size());
+#if USE(DIRECT2D)
+        notImplemented();
+#else
         CGContextDrawImage(context.platformContext(), CGRectMake(0, 0, paintRect.width(), paintRect.height()), image.get());
+#endif
         context.restore();
         image = 0;
     }
index ce58a25..d0f7a29 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "GraphicsLayerCA.h"
 
+#if USE(CA)
+
 #include "Animation.h"
 #include "DisplayListRecorder.h"
 #include "DisplayListReplayer.h"
@@ -3993,3 +3995,5 @@ double GraphicsLayerCA::backingStoreMemoryEstimate() const
 }
 
 } // namespace WebCore
+
+#endif
index c52227d..373ded9 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "PlatformCALayer.h"
 
+#if USE(CA)
+
 #include <CoreFoundation/CoreFoundation.h>
 #include <CoreText/CoreText.h>
 #include "GraphicsContextCG.h"
@@ -38,8 +40,6 @@
 #include "CoreTextSPIWin.h"
 #endif
 
-#if USE(CA)
-
 namespace WebCore {
 
 static GraphicsLayer::PlatformLayerID generateLayerID()
index 5a5f7fe..17c150f 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "TileController.h"
 
+#if USE(CG)
+
 #include "IntRect.h"
 #include "Logging.h"
 #include "PlatformCALayer.h"
@@ -735,3 +737,5 @@ void TileController::removeUnparentedTilesNow()
 #endif
 
 } // namespace WebCore
+
+#endif
index b9c02cc..2d02e85 100644 (file)
@@ -24,6 +24,9 @@
  */
 
 #include "config.h"
+
+#if USE(CG)
+
 #include "TileGrid.h"
 
 #include "GraphicsContext.h"
@@ -762,3 +765,5 @@ void TileGrid::removeUnparentedTilesNow()
 #endif
 
 } // namespace WebCore
+
+#endif
index a8de019..325336f 100644 (file)
@@ -51,7 +51,9 @@ public:
     TileGrid(TileController&);
     ~TileGrid();
 
+#if USE(CA)
     PlatformCALayer& containerLayer() { return m_containerLayer; }
+#endif
 
     void setIsZoomedOutTileGrid(bool);
 
@@ -83,7 +85,9 @@ public:
     double retainedTileBackingStoreMemory() const;
     unsigned blankPixelCount() const;
 
+#if USE(CG)
     void drawTileMapContents(CGContextRef, CGRect layerBounds) const;
+#endif
 
 #if PLATFORM(IOS)
     unsigned numberOfUnparentedTiles() const { return m_cohortList.size(); }
@@ -150,7 +154,9 @@ private:
     bool isUsingDisplayListDrawing(PlatformCALayer*) const override;
 
     TileController& m_controller;
+#if USE(CA)
     Ref<PlatformCALayer> m_containerLayer;
+#endif
 
     typedef HashMap<TileIndex, TileInfo> TileMap;
     TileMap m_tiles;
index 34139c7..d56e950 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "CACFLayerTreeHost.h"
 
+#if USE(CA)
+
 #include "CACFLayerTreeHostClient.h"
 #include "DebugPageOverlays.h"
 #include "DefWndProcWindowClass.h"
@@ -374,3 +376,5 @@ void CACFLayerTreeHost::updateDebugInfoLayer(bool showLayer)
 }
 
 }
+
+#endif
index 947b3f7..0db88c8 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "LayerChangesFlusher.h"
 
+#if USE(CA)
+
 #include "AbstractCACFLayerTreeHost.h"
 #include "StructuredExceptionHandlerSuppressor.h"
 #include <wtf/StdLibExtras.h>
@@ -129,3 +131,5 @@ void LayerChangesFlusher::removeHook()
 }
 
 } // namespace WebCore
+
+#endif
index 62a24fc..27de2b5 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "config.h"
 
-#if PLATFORM(WIN)
+#if PLATFORM(WIN) && USE(CA)
 #include "PlatformCAAnimationWin.h"
 
 #include "FloatConversion.h"
index ac3f9bc..efc6dba 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef PlatformCAAnimationWin_h
 #define PlatformCAAnimationWin_h
 
-#if PLATFORM(WIN)
+#if PLATFORM(WIN) && USE(CA)
 
 #include "PlatformCAAnimation.h"
 #include <wtf/RetainPtr.h>
index beb397b..73d8950 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "PlatformCAFilters.h"
 
+#if USE(CA)
+
 using namespace WebCore;
 
 void PlatformCAFilters::setFiltersOnLayer(PlatformLayer* layer, const FilterOperations& filters)
@@ -44,3 +46,5 @@ const char* PlatformCAFilters::animatedFilterPropertyName(FilterOperation::Opera
     // Hardware filter animation not implemented on Windows.
     return "";
 }
+
+#endif
index 7854030..1cb9206 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "PlatformCALayerWin.h"
 
+#if USE(CA)
+
 #include "AbstractCACFLayerTreeHost.h"
 #include "FontCascade.h"
 #include "GDIUtilities.h"
@@ -953,3 +955,5 @@ void PlatformCALayerWin::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloa
     cg.setFillColor(Color::black);
     cg.drawText(font, TextRun(text), IntPoint(x, y));
 }
+
+#endif
index 43cd9e4..aa8a9a7 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "PlatformCALayerWinInternal.h"
 
+#if USE(CA)
+
 #include "FontCascade.h"
 #include "GraphicsContext.h"
 #include "PlatformCALayer.h"
@@ -323,3 +325,5 @@ void PlatformCALayerWinInternal::setBorderColor(const Color& value)
 
     CACFLayerSetBorderColor(owner()->platformLayer(), color.get());
 }
+
+#endif
index 50a6ebf..b150753 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WKCACFViewLayerTreeHost.h"
 
+#if USE(CA)
+
 #include "GDIUtilities.h"
 #include "PlatformCALayer.h"
 #include "SoftLinking.h"
@@ -197,3 +199,5 @@ GraphicsDeviceAdapter* WKCACFViewLayerTreeHost::graphicsDeviceAdapter() const
 #endif
 
 } // namespace WebCore
+
+#endif
index 374caf7..31665bf 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebTiledBackingLayerWin.h"
 
+#if USE(CA)
+
 #include "GraphicsContext.h"
 #include "PlatformCALayer.h"
 #include "TileController.h"
@@ -180,3 +182,5 @@ void WebTiledBackingLayerWin::invalidate()
     ASSERT(m_tileController);
     m_tileController = nullptr;
 }
+
+#endif
index f42103d..750d584 100644 (file)
@@ -27,6 +27,8 @@
 #include "config.h"
 #include "Gradient.h"
 
+#if USE(CG)
+
 #include "GraphicsContextCG.h"
 #include <CoreGraphics/CoreGraphics.h>
 #include <wtf/RetainPtr.h>
@@ -105,3 +107,5 @@ void Gradient::paint(CGContextRef context)
 }
 
 } //namespace
+
+#endif
index 7aa485f..4b7e1b4 100644 (file)
@@ -27,6 +27,8 @@
 #include "config.h"
 #include "GraphicsContextCG.h"
 
+#if USE(CG)
+
 #include "AffineTransform.h"
 #include "CoreGraphicsSPI.h"
 #include "DisplayListRecorder.h"
@@ -1048,7 +1050,6 @@ IntRect GraphicsContext::clipBounds() const
         return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
     }
 
-
     return enclosingIntRect(CGContextGetClipBoundingBox(platformContext()));
 }
 
@@ -1905,3 +1906,5 @@ void GraphicsContext::platformStrokeEllipse(const FloatRect& ellipse)
 }
 
 }
+
+#endif
index 84c8e70..c48e198 100644 (file)
@@ -28,6 +28,8 @@
 #include "config.h"
 #include "ImageBuffer.h"
 
+#if USE(CG)
+
 #include "BitmapImage.h"
 #include "GraphicsContext.h"
 #include "GraphicsContextCG.h"
@@ -591,3 +593,5 @@ String ImageDataToDataURL(const ImageData& source, const String& mimeType, const
 }
 
 } // namespace WebCore
+
+#endif
index cebe987..b2adf53 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "ImageBufferData.h"
 
+#if USE(CG)
+
 #include "GraphicsContext.h"
 #include "IntRect.h"
 #include <CoreGraphics/CoreGraphics.h>
@@ -544,3 +546,5 @@ void ImageBufferData::putData(Uint8ClampedArray*& source, const IntSize& sourceS
 }
 
 } // namespace WebCore
+
+#endif
index 450a5c0..171ac61 100644 (file)
@@ -38,6 +38,7 @@
 #include "ImageObserver.h"
 #include "IntRect.h"
 #include "Length.h"
+#include "NotImplemented.h"
 #include "SharedBuffer.h"
 #include "TextStream.h"
 #include <CoreGraphics/CGContext.h>
@@ -344,8 +345,12 @@ void PDFDocumentImage::drawPDFPage(GraphicsContext& context)
 
     context.translate(-m_cropBox.x(), -m_cropBox.y());
 
+#if USE(DIRECT2D)
+    notImplemented();
+#else
     // CGPDF pages are indexed from 1.
     CGContextDrawPDFPage(context.platformContext(), CGPDFDocumentGetPage(m_document.get(), 1));
+#endif
 }
 
 #endif // !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
index 3daa139..7186009 100644 (file)
@@ -27,6 +27,8 @@
 #include "config.h"
 #include "Pattern.h"
 
+#if USE(CG)
+
 #include "AffineTransform.h"
 #include "GraphicsContext.h"
 
@@ -90,3 +92,5 @@ CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran
 }
 
 }
+
+#endif
index b398179..4faf77e 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "SubimageCacheWithTimer.h"
 
+#if USE(CG)
+
 #include <wtf/Vector.h>
 
 #if CACHE_SUBIMAGES
@@ -114,3 +116,5 @@ SubimageCacheWithTimer& subimageCache()
 }
 
 #endif
+
+#endif
index af2ae05..5e88720 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "FontCascade.h"
 
+#if USE(CG)
+
 #include "AffineTransform.h"
 #include "FloatConversion.h"
 #include "Font.h"
@@ -218,3 +220,5 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
 }
 
 }
+
+#endif
index b488e90..8920071 100644 (file)
@@ -24,6 +24,8 @@
 #include "config.h"
 #include "FontPlatformData.h"
 
+#if USE(CG)
+
 #include "SharedGDIObject.h"
 #include <ApplicationServices/ApplicationServices.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
@@ -135,3 +137,5 @@ bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
 }
 
 }
+
+#endif
index ec98ddd..ae3cab3 100644 (file)
@@ -29,6 +29,8 @@
 #include "config.h"
 #include "GlyphPage.h"
 
+#if USE(CG)
+
 #include "Font.h"
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 
@@ -58,3 +60,5 @@ bool GlyphPage::fill(UChar* buffer, unsigned bufferLength)
 }
 
 }
+
+#endif
index 23c2a9a..ceb4ee3 100644 (file)
@@ -29,7 +29,7 @@
 #if USE(DIRECT2D)
 
 #include "Font.h"
-#include "TextAnalysisHelper.h"
+#include "TextAnalyzerHelper.h"
 #include <dwrite.h>
 
 namespace WebCore {
index 4afd01f..74a8fbd 100644 (file)
@@ -98,7 +98,7 @@ void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
         // for which m_p0 == m_p1.
         ASSERT(m_p0 == m_p1);
 
-        D2D1_MATRIX_3X2_F ctm;
+        D2D1_MATRIX_3X2_F ctm = { };
         d2dContext->GetTransform(&ctm);
 
         AffineTransform transform(ctm);
index 24eda46..3eceb93 100644 (file)
@@ -336,14 +336,14 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
     notImplemented();
 }
 
-static equalRadiusWidths(const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
+static bool equalRadiusWidths(const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
 {
     return topLeftRadius.width() == topRightRadius.width()
         && topRightRadius.width() == bottomLeftRadius.width()
         && bottomLeftRadius.width() == bottomRightRadius.width();
 }
 
-static equalRadiusHeights(const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
+static bool equalRadiusHeights(const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
 {
     return topLeftRadius.height() == bottomLeftRadius.height()
         && bottomLeftRadius.height() == topRightRadius.height()
@@ -414,7 +414,7 @@ void Path::addArc(const FloatPoint& center, float radius, float startAngle, floa
     float firstArcEnd = startAngle + maxSweep;
     drawArcSection(m_activePath.get(), center, radius, startAngle, firstArcEnd, clockwise);
 
-    if (areEssentiallyEqual(firstArcEnd, endAngle))
+    if (WTF::areEssentiallyEqual(firstArcEnd, endAngle))
         return;
 
     drawArcSection(m_activePath.get(), center, radius, firstArcEnd, endAngle, clockwise);
index 9bf3085..99b7c55 100644 (file)
@@ -29,6 +29,8 @@
 #include "config.h"
 #include "Font.h"
 
+#if USE(CG)
+
 #include "CoreTextSPIWin.h"
 #include "FloatRect.h"
 #include "FontCache.h"
@@ -152,3 +154,5 @@ float Font::platformWidthForGlyph(Glyph glyph) const
 }
 
 }
+
+#endif
index dce3971..d1bd43b 100644 (file)
 #include <wtf/MathExtras.h>
 #include <wtf/win/GDIObject.h>
 
+#if USE(DIRECT2D)
+#include <dwrite.h>
+#endif
+
 namespace WebCore {
 
 const float cSmallCapsFontSizeMultiplier = 0.7f;
index 4b4e377..2289b8f 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "DragImage.h"
 
+#if USE(CG)
+
 #include "BitmapInfo.h"
 #include "CachedImage.h"
 #include "GraphicsContextCG.h"
@@ -146,3 +148,5 @@ DragImageRef createDragImageFromImage(Image* img, ImageOrientationDescription)
 }
     
 }
+
+#endif
diff --git a/Source/WebCore/platform/win/DragImageDirect2D.cpp b/Source/WebCore/platform/win/DragImageDirect2D.cpp
new file mode 100644 (file)
index 0000000..e3c57ae
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2016 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "DragImage.h"
+
+#if USE(DIRECT2D)
+
+#include "BitmapInfo.h"
+#include "CachedImage.h"
+#include "GraphicsContext.h"
+#include "HWndDC.h"
+#include "Image.h"
+#include "NotImplemented.h"
+
+#include <d2d1.h>
+#include <windows.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/win/GDIObject.h>
+
+namespace WebCore {
+
+void deallocContext(ID2D1RenderTarget* renderTarget)
+{
+    if (renderTarget)
+        renderTarget->Release();
+}
+
+GDIObject<HBITMAP> allocImage(HDC dc, IntSize size, ID2D1RenderTarget** targetRef)
+{
+    BitmapInfo bmpInfo = BitmapInfo::create(size);
+
+    LPVOID bits = nullptr;
+    auto hbmp = adoptGDIObject(::CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, &bits, 0, 0));
+
+    if (!targetRef || !hbmp)
+        return hbmp;
+
+    // FIXME: Use GDI Interop layer to create HBITMAP from D2D Bitmap
+    notImplemented();
+    return hbmp;
+}
+
+DragImageRef scaleDragImage(DragImageRef imageRef, FloatSize scale)
+{
+    // FIXME: due to the way drag images are done on windows we need 
+    // to preprocess the alpha channel <rdar://problem/5015946>
+    if (!imageRef)
+        return nullptr;
+
+    GDIObject<HBITMAP> hbmp;
+    auto image = adoptGDIObject(imageRef);
+
+    IntSize srcSize = dragImageSize(image.get());
+    IntSize dstSize(static_cast<int>(srcSize.width() * scale.width()), static_cast<int>(srcSize.height() * scale.height()));
+
+    HWndDC dc(nullptr);
+    auto dstDC = adoptGDIObject(::CreateCompatibleDC(dc));
+    if (dstDC)
+        notImplemented();
+
+    if (!hbmp)
+        hbmp.swap(image);
+    return hbmp.leak();
+}
+
+DragImageRef createDragImageFromImage(Image* img, ImageOrientationDescription)
+{
+    HWndDC dc(nullptr);
+    auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc));
+    if (!workingDC)
+        return nullptr;
+
+    notImplemented();
+    return nullptr;
+}
+    
+}
+
+#endif
index b52a6c9..d461d81 100644 (file)
@@ -32,6 +32,7 @@
 #include "GraphicsContext.h"
 #include "HTMLMediaElement.h"
 #include "HTMLNames.h"
+#include "NotImplemented.h"
 #include "PaintInfo.h"
 #include "RenderTheme.h"
 
@@ -128,6 +129,13 @@ void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle& style)
 
 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
 {
+#if USE(DIRECT2D)
+    UNUSED_PARAM(part);
+    UNUSED_PARAM(o);
+    UNUSED_PARAM(paintInfo);
+    UNUSED_PARAM(r);
+    notImplemented();
+#else
     GraphicsContextStateSaver stateSaver(paintInfo.context());
 
     switch (part) {
@@ -214,7 +222,7 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, c
         ASSERT_NOT_REACHED();
         break;
     }
-
+#endif
     return false;
 }