Changeset 206742 in webkit


Ignore:
Timestamp:
Oct 3, 2016 1:22:57 PM (7 years ago)
Author:
Brent Fulgham
Message:

[Win][Direct2D] Add D2D Bitmap Image handling code
https://bugs.webkit.org/show_bug.cgi?id=162761

Reviewed by Dean Jackson.

This patch lands a set of new files that implement
Image and BitmapImage features on Windows using
Direct2D.

The desired ID2D1RenderTarget handle is needed by the
image decoder so that it can load the resulting bitmap
into the GPU.

No new tests until complete backend lands.

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::draw): Tell the Direct2D image decoder
which render target to use.

  • platform/graphics/BitmapImage.h:
  • platform/graphics/ImageBuffer.cpp:
  • platform/graphics/ImageBuffer.h:
  • platform/graphics/ImageBufferData.h:
  • platform/graphics/ImageFrameCache.cpp:

(WebCore::ImageFrameCache::setRenderTarget): Added.

  • platform/graphics/ImageFrameCache.h:

(WebCore::ImageFrameCache::decoder): Added.

  • platform/graphics/ImageSource.cpp:
  • platform/graphics/ImageSource.h:

(WebCore::ImageSource::setRenderTarget):

  • platform/graphics/win/ImageBufferDataDirect2D.cpp: Added.
  • platform/graphics/win/ImageBufferDataDirect2D.h: Added.
  • platform/graphics/win/ImageBufferDirect2D.cpp: Added.
  • platform/graphics/win/ImageCGWin.cpp:
  • platform/graphics/win/ImageDecoderDirect2D.cpp: Added.
  • platform/graphics/win/ImageDecoderDirect2D.h: Added.
  • platform/graphics/win/ImageDirect2D.cpp: Added.
  • platform/graphics/win/NativeImageDirect2D.cpp: Added.
Location:
trunk/Source/WebCore
Files:
7 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206740 r206742  
     12016-10-03  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win][Direct2D] Add D2D Bitmap Image handling code
     4        https://bugs.webkit.org/show_bug.cgi?id=162761
     5
     6        Reviewed by Dean Jackson.
     7
     8        This patch lands a set of new files that implement
     9        Image and BitmapImage features on Windows using
     10        Direct2D.
     11
     12        The desired ID2D1RenderTarget handle is needed by the
     13        image decoder so that it can load the resulting bitmap
     14        into the GPU.
     15
     16        No new tests until complete backend lands.
     17
     18        * platform/graphics/BitmapImage.cpp:
     19        (WebCore::BitmapImage::draw): Tell the Direct2D image decoder
     20        which render target to use.
     21        * platform/graphics/BitmapImage.h:
     22        * platform/graphics/ImageBuffer.cpp:
     23        * platform/graphics/ImageBuffer.h:
     24        * platform/graphics/ImageBufferData.h:
     25        * platform/graphics/ImageFrameCache.cpp:
     26        (WebCore::ImageFrameCache::setRenderTarget): Added.
     27        * platform/graphics/ImageFrameCache.h:
     28        (WebCore::ImageFrameCache::decoder): Added.
     29        * platform/graphics/ImageSource.cpp:
     30        * platform/graphics/ImageSource.h:
     31        (WebCore::ImageSource::setRenderTarget):
     32        * platform/graphics/win/ImageBufferDataDirect2D.cpp: Added.
     33        * platform/graphics/win/ImageBufferDataDirect2D.h: Added.
     34        * platform/graphics/win/ImageBufferDirect2D.cpp: Added.
     35        * platform/graphics/win/ImageCGWin.cpp:
     36        * platform/graphics/win/ImageDecoderDirect2D.cpp: Added.
     37        * platform/graphics/win/ImageDecoderDirect2D.h: Added.
     38        * platform/graphics/win/ImageDirect2D.cpp: Added.
     39        * platform/graphics/win/NativeImageDirect2D.cpp: Added.
     40
    1412016-10-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    242
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r206631 r206742  
    142142        return;
    143143
     144#if USE(DIRECT2D)
     145    setRenderTarget(context);
     146#endif
     147
    144148#if PLATFORM(IOS)
    145149    startAnimation(DoNotCatchUp);
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r206720 r206742  
    123123    Vector<NativeImagePtr> framesNativeImages() override;
    124124#endif
     125#if USE(DIRECT2D)
     126    void setRenderTarget(GraphicsContext&);
     127#endif
    125128
    126129protected:
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp

    r202927 r206742  
    8282}
    8383
    84 #if !USE(CG)
     84#if !(USE(CG) || USE(DIRECT2D))
    8585FloatSize ImageBuffer::sizeForDestinationSize(FloatSize size) const
    8686{
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.h

    r206631 r206742  
    4040#include <wtf/RefPtr.h>
    4141#include <wtf/Vector.h>
     42
     43#if PLATFORM(WIN)
     44interface ID2D1RenderTarget;
     45#endif
    4246
    4347namespace WebCore {
     
    150154    static RetainPtr<CGImageRef> sinkIntoNativeImage(std::unique_ptr<ImageBuffer>);
    151155    void flushContext() const;
     156#elif USE(DIRECT2D)
     157    void flushContext() const;
    152158#endif
    153159   
     
    176182#if USE(CG)
    177183    ImageBuffer(const FloatSize&, float resolutionScale, CGColorSpaceRef, RenderingMode, bool& success);
     184#elif USE(DIRECT2D)
     185    ImageBuffer(const FloatSize&, float resolutionScale, ColorSpace, RenderingMode, ID2D1RenderTarget*, bool& success);
    178186#endif
    179187};
  • trunk/Source/WebCore/platform/graphics/ImageBufferData.h

    r173949 r206742  
    2626#if USE(CG)
    2727#include "ImageBufferDataCG.h"
     28#elif USE(DIRECT2D)
     29#include "ImageBufferDataDirect2D.h"
    2830#elif USE(CAIRO)
    2931#include "ImageBufferDataCairo.h"
  • trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp

    r206635 r206742  
    3232#if USE(CG)
    3333#include "ImageDecoderCG.h"
     34#elif USE(DIRECT2D)
     35#include "GraphicsContext.h"
     36#include "ImageDecoderDirect2D.h"
     37#include <WinCodec.h>
    3438#else
    3539#include "ImageDecoder.h"
     
    375379}
    376380
    377 }
     381#if USE(DIRECT2D)
     382void ImageFrameCache::setRenderTarget(GraphicsContext& context)
     383{
     384    if (m_decoder)
     385        m_decoder->setRenderTarget(context.platformContext());
     386}
     387#endif
     388
     389}
  • trunk/Source/WebCore/platform/graphics/ImageFrameCache.h

    r206635 r206742  
    3434namespace WebCore {
    3535
     36class GraphicsContext;
    3637class Image;
    3738class ImageDecoder;
     
    4445
    4546    void setDecoder(ImageDecoder* decoder) { m_decoder = decoder; }
     47    ImageDecoder* decoder() const { return m_decoder; }
     48
    4649    unsigned decodedSize() const { return m_decodedSize; }
    4750    void destroyDecodedData(bool destroyAll = true, size_t count = 0);
     
    7982    ImageOrientation frameOrientationAtIndex(size_t);
    8083    NativeImagePtr frameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default);
     84
     85#if USE(DIRECT2D)
     86    void setRenderTarget(GraphicsContext&);
     87#endif
    8188
    8289private:
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r206526 r206742  
    3232#if USE(CG)
    3333#include "ImageDecoderCG.h"
     34#elif USE(DIRECT2D)
     35#include "ImageDecoderDirect2D.h"
     36#include <WinCodec.h>
    3437#else
    3538#include "ImageDecoder.h"
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r206481 r206742  
    3939namespace WebCore {
    4040
     41class GraphicsContext;
    4142class ImageDecoder;
    4243class ImageOrientation;
     
    9697    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default);
    9798
     99#if USE(DIRECT2D)
     100    void setRenderTarget(GraphicsContext& context) { m_frameCache.setRenderTarget(context); }
     101#endif
     102
    98103private:
    99104    void clearFrameBufferCache(size_t);
  • trunk/Source/WebCore/platform/graphics/NativeImage.h

    r206156 r206742  
    4040#endif
    4141
     42#if USE(DIRECT2D)
     43#include "COMPtr.h"
     44#include <d2d1.h>
     45#endif
     46
    4247namespace WebCore {
    4348
     
    4954#if USE(CG)
    5055typedef RetainPtr<CGImageRef> NativeImagePtr;
     56#elif USE(DIRECT2D)
     57typedef COMPtr<ID2D1Bitmap> NativeImagePtr;
    5158#elif USE(CAIRO)
    5259typedef RefPtr<cairo_surface_t> NativeImagePtr;
  • trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp

    r198655 r206742  
    2626#include "config.h"
    2727#include "Image.h"
     28
     29#if USE(CG)
    2830
    2931#include "BitmapImage.h"
     
    107109
    108110} // namespace WebCore
     111
     112#endif
Note: See TracChangeset for help on using the changeset viewer.