Changeset 206773 in webkit


Ignore:
Timestamp:
Oct 4, 2016 11:31:21 AM (7 years ago)
Author:
Brent Fulgham
Message:

[Win][Direct2D] Add initial D2D GraphicsContext implementation
https://bugs.webkit.org/show_bug.cgi?id=162917

Reviewed by Dean Jackson.

This patch lands a set of new files that implement the GraphicsContext
features on Windows using Direct2D.

No new tests until complete backend lands.

  • platform/graphics/Color.h: Add new casting operator.
  • platform/graphics/FloatSize.h: Ditto.
  • platform/graphics/GraphicsContext.cpp: Update for Direct2D

implementation.

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/win/ColorDirect2D.cpp:

(WebCore::Color::operator D2D1_VECTOR_4F): Added.

  • platform/graphics/win/GraphicsContextCGWin.cpp: Add compiler

guard to avoid building when using Direct2D.

  • platform/graphics/win/GraphicsContextDirect2D.cpp: Added.
  • platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h: Added.
  • platform/graphics/win/GraphicsContextWin.cpp: Update for Direct2D

includes.

  • platform/graphics/win/TransformationMatrixDirect2D.cpp: Fix comment.
Location:
trunk/Source/WebCore
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206772 r206773  
     12016-10-04  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win][Direct2D] Add initial D2D GraphicsContext implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=162917
     5
     6        Reviewed by Dean Jackson.
     7
     8        This patch lands a set of new files that implement the GraphicsContext
     9        features on Windows using Direct2D.
     10
     11        No new tests until complete backend lands.
     12
     13        * platform/graphics/Color.h: Add new casting operator.
     14        * platform/graphics/FloatSize.h: Ditto.
     15        * platform/graphics/GraphicsContext.cpp: Update for Direct2D
     16        implementation.
     17        * platform/graphics/GraphicsContext.h:
     18        * platform/graphics/win/ColorDirect2D.cpp:
     19        (WebCore::Color::operator D2D1_VECTOR_4F): Added.
     20        * platform/graphics/win/GraphicsContextCGWin.cpp: Add compiler
     21        guard to avoid building when using Direct2D.
     22        * platform/graphics/win/GraphicsContextDirect2D.cpp: Added.
     23        * platform/graphics/win/GraphicsContextPlatformPrivateDirect2D.h: Added.
     24        * platform/graphics/win/GraphicsContextWin.cpp: Update for Direct2D
     25        includes.
     26        * platform/graphics/win/TransformationMatrixDirect2D.cpp: Fix comment.
     27
    1282016-10-04  Carlos Garcia Campos  <cgarcia@igalia.com>
    229
  • trunk/Source/WebCore/platform/graphics/Color.h

    r206245 r206773  
    4545typedef D3DCOLORVALUE D2D_COLOR_F;
    4646typedef D2D_COLOR_F D2D1_COLOR_F;
     47struct D2D_VECTOR_4F;
     48typedef D2D_VECTOR_4F D2D1_VECTOR_4F;
    4749#endif
    4850
     
    185187    WEBCORE_EXPORT Color(D2D1_COLOR_F);
    186188    WEBCORE_EXPORT operator D2D1_COLOR_F() const;
     189    WEBCORE_EXPORT operator D2D1_VECTOR_4F() const;
    187190#endif
    188191
  • trunk/Source/WebCore/platform/graphics/FloatSize.h

    r205881 r206773  
    131131
    132132#if PLATFORM(WIN)
    133     WEBCORE_EXPORT explicit FloatSize(const D2D1_SIZE_F&); // don't do this implicitly since it's lossy
     133    WEBCORE_EXPORT FloatSize(const D2D1_SIZE_F&);
    134134    operator D2D1_SIZE_F() const;
    135135#endif
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r204654 r206773  
    835835}
    836836
    837 #if !USE(CG) && !USE(CAIRO)
     837#if !USE(CG) && !USE(DIRECT2D) && !USE(CAIRO)
    838838IntRect GraphicsContext::clipBounds() const
    839839{
     
    903903}
    904904
    905 #if !USE(CG) && !USE(CAIRO)
     905#if !USE(CG) && !USE(DIRECT2D) && !USE(CAIRO)
    906906void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color)
    907907{
     
    958958}
    959959
    960 #if !USE(CG)
     960#if !USE(CG) && !USE(DIRECT2D)
    961961// Implement this if you want to go push the drawing mode into your native context immediately.
    962962void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags)
     
    971971#endif
    972972
    973 #if !USE(CG)
     973#if !USE(CG) && !USE(DIRECT2D)
    974974void GraphicsContext::setPlatformShouldSmoothFonts(bool)
    975975{
     
    977977#endif
    978978
    979 #if !USE(CG) && !USE(CAIRO)
     979#if !USE(CG) && !USE(DIRECT2D) && !USE(CAIRO)
    980980bool GraphicsContext::isAcceleratedContext() const
    981981{
     
    10131013}
    10141014
    1015 #if !USE(CG)
     1015#if !USE(CG) && !USE(DIRECT2D)
    10161016void GraphicsContext::platformApplyDeviceScaleFactor(float)
    10171017{
     
    10611061}
    10621062
    1063 #if !USE(CG)
     1063#if !USE(CG) && !USE(DIRECT2D)
    10641064void GraphicsContext::platformFillEllipse(const FloatRect& ellipse)
    10651065{
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r206631 r206773  
    11/*
    2  * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2003-2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008-2009 Torch Mobile, Inc.
    44 *
     
    3939#if USE(CG)
    4040typedef struct CGContext PlatformGraphicsContext;
     41#elif USE(DIRECT2D)
     42interface ID2D1DCRenderTarget;
     43interface ID2D1RenderTarget;
     44interface ID2D1Factory;
     45typedef ID2D1RenderTarget PlatformGraphicsContext;
    4146#elif USE(CAIRO)
    4247namespace WebCore {
     
    301306    const GraphicsContextState& state() const { return m_state; }
    302307
    303 #if USE(CG) || USE(CAIRO)
     308#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
    304309    WEBCORE_EXPORT void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = ImageOrientation());
    305310#endif
    306311
    307 #if USE(CG)
     312#if USE(CG) || USE(DIRECT2D)
    308313    void applyStrokePattern();
    309314    void applyFillPattern();
     
    505510#else
    506511    GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
     512    GraphicsContext(HDC, ID2D1DCRenderTarget**, RECT, bool hasAlpha = false); // FIXME: To be removed.
    507513
    508514    // When set to true, child windows should be rendered into this context
     
    541547    void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
    542548#endif
     549    WEBCORE_EXPORT static ID2D1Factory* systemFactory();
     550    WEBCORE_EXPORT static ID2D1RenderTarget* defaultRenderTarget();
     551
     552    WEBCORE_EXPORT void setDidBeginDraw(bool);
     553    WEBCORE_EXPORT bool didBeginDraw() const;
     554    D2D1_COLOR_F colorWithGlobalAlpha(const Color&) const;
     555
     556    ID2D1SolidColorBrush* solidStrokeBrush();
     557    ID2D1SolidColorBrush* solidFillBrush();
    543558#else // PLATFORM(WIN)
    544559    bool shouldIncludeChildWindows() const { return false; }
     
    558573#if PLATFORM(WIN) && !USE(WINGDI)
    559574    void platformInit(HDC, bool hasAlpha = false);
     575    void platformInit(HDC, ID2D1RenderTarget**, RECT, bool hasAlpha = false);
     576    void platformInit(ID2D1RenderTarget*);
     577#endif
     578
     579#if USE(DIRECT2D)
     580    void drawWithoutShadow(const FloatRect& boundingRect, const std::function<void(ID2D1RenderTarget*)>&);
     581    void drawWithShadow(const FloatRect& boundingRect, const std::function<void(ID2D1RenderTarget*)>&);
    560582#endif
    561583
  • trunk/Source/WebCore/platform/graphics/win/ColorDirect2D.cpp

    r206056 r206773  
    3030
    3131#include <d2d1.h>
     32#include <d2d1_1helper.h>
    3233
    3334namespace WebCore {
     
    4647}
    4748
     49Color::operator D2D1_VECTOR_4F() const
     50{
     51    float r, g, b, a;
     52    getRGBA(r, g, b, a);
     53    return D2D1::Vector4F(r, g, b, a);
     54}
     55
    4856}
    4957
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp

    r196439 r206773  
    2727#include "GraphicsContextCG.h"
    2828
     29#if USE(CG)
     30
    2931#include "AffineTransform.h"
    3032#include "GraphicsContextPlatformPrivateCG.h"
     
    263265
    264266}
     267#endif
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp

    r191326 r206773  
    2929#if USE(CG)
    3030#include "GraphicsContextPlatformPrivateCG.h"
     31#elif USE(DIRECT2D)
     32#include "GraphicsContextPlatformPrivateDirect2D.h"
    3133#elif USE(CAIRO)
    3234#include "GraphicsContextPlatformPrivateCairo.h"
     
    145147}
    146148
    147 #if PLATFORM(WIN)
     149#if PLATFORM(WIN) && !USE(DIRECT2D)
    148150void GraphicsContextPlatformPrivate::save()
    149151{
  • trunk/Source/WebCore/platform/graphics/win/TransformationMatrixDirect2D.cpp

    r205871 r206773  
    7373}
    7474
    75 #endif // USE(DIRECT2D)
     75#endif
Note: See TracChangeset for help on using the changeset viewer.