diff options
22 files changed, 529 insertions, 237 deletions
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index 0ec540e..bc44131 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -61,14 +61,17 @@ SkDevice* PdfMetafileSkia::StartPageForVectorCanvas( transform.preScale(SkFloatToScalar(scale_factor), SkFloatToScalar(scale_factor)); + // TODO(ctguil): Refactor: don't create the PDF device explicitly here. SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height()); SkISize pdf_content_size = SkISize::Make(content_area.width(), content_area.height()); SkRefPtr<SkPDFDevice> pdf_device = - new skia::VectorPlatformDeviceSkia(pdf_page_size, pdf_content_size, - transform); - data_->current_page_ = pdf_device; - return pdf_device.get(); + new SkPDFDevice(pdf_page_size, pdf_content_size, transform); + pdf_device->unref(); // SkRefPtr and new both took a reference. + skia::VectorPlatformDeviceSkia* device = + new skia::VectorPlatformDeviceSkia(pdf_device.get()); + data_->current_page_ = device->PdfDevice(); + return device; } bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, diff --git a/skia/ext/bitmap_platform_device_linux.cc b/skia/ext/bitmap_platform_device_linux.cc index 3087adc..782b78f 100644 --- a/skia/ext/bitmap_platform_device_linux.cc +++ b/skia/ext/bitmap_platform_device_linux.cc @@ -120,9 +120,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, BitmapPlatformDevice::BitmapPlatformDevice( const SkBitmap& bitmap, BitmapPlatformDeviceData* data) - : SkDevice(bitmap), + : PlatformDevice(bitmap), data_(data) { - SetPlatformDevice(this, this); } BitmapPlatformDevice::~BitmapPlatformDevice() { @@ -147,12 +146,6 @@ cairo_t* BitmapPlatformDevice::BeginPlatformPaint() { return cairo; } -void BitmapPlatformDevice::DrawToNativeContext( - PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { - // Should never be called on Linux. - SkASSERT(false); -} - void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, const SkRegion& region, const SkClipStack&) { diff --git a/skia/ext/bitmap_platform_device_linux.h b/skia/ext/bitmap_platform_device_linux.h index 57c12ce..e5e4437 100644 --- a/skia/ext/bitmap_platform_device_linux.h +++ b/skia/ext/bitmap_platform_device_linux.h @@ -7,9 +7,8 @@ #pragma once #include "base/basictypes.h" -#include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "skia/ext/platform_device.h" +#include "skia/ext/platform_device_linux.h" typedef struct _cairo_surface cairo_surface_t; @@ -57,7 +56,7 @@ namespace skia { // shared memory between the renderer and the main process at least. In this // case we'll probably create the buffer from a precreated region of memory. // ----------------------------------------------------------------------------- -class BitmapPlatformDevice : public PlatformDevice, public SkDevice { +class BitmapPlatformDevice : public PlatformDevice { // A reference counted cairo surface class BitmapPlatformDeviceData; @@ -74,24 +73,22 @@ class BitmapPlatformDevice : public PlatformDevice, public SkDevice { static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); // This doesn't take ownership of |data| - static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, - uint8_t* data); + static BitmapPlatformDevice* Create(int width, int height, + bool is_opaque, uint8_t* data); - virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE; + virtual void MakeOpaque(int x, int y, int width, int height); // Overridden from SkDevice: virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, - const SkClipStack&) OVERRIDE; + const SkClipStack&); // Overridden from PlatformDevice: - virtual cairo_t* BeginPlatformPaint() OVERRIDE; - virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, - const PlatformRect* src_rect) OVERRIDE; + virtual cairo_t* BeginPlatformPaint(); protected: virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, - int height, bool isOpaque, - Usage usage) OVERRIDE; + int height, bool isOpaque, + Usage usage); private: static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc index 15bf566..d6bfc50 100644 --- a/skia/ext/bitmap_platform_device_mac.cc +++ b/skia/ext/bitmap_platform_device_mac.cc @@ -180,9 +180,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::CreateWithData(uint8_t* data, // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. BitmapPlatformDevice::BitmapPlatformDevice( BitmapPlatformDeviceData* data, const SkBitmap& bitmap) - : SkDevice(bitmap), + : PlatformDevice(bitmap), data_(data) { - SetPlatformDevice(this, this); } BitmapPlatformDevice::~BitmapPlatformDevice() { diff --git a/skia/ext/bitmap_platform_device_mac.h b/skia/ext/bitmap_platform_device_mac.h index da14528..fddbaad 100644 --- a/skia/ext/bitmap_platform_device_mac.h +++ b/skia/ext/bitmap_platform_device_mac.h @@ -7,8 +7,7 @@ #pragma once #include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "skia/ext/platform_device.h" +#include "skia/ext/platform_device_mac.h" namespace skia { @@ -26,7 +25,7 @@ namespace skia { // For us, that other bitmap will become invalid as soon as the device becomes // invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE // DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead. -class BitmapPlatformDevice : public PlatformDevice, public SkDevice { +class BitmapPlatformDevice : public PlatformDevice { public: // |context| may be NULL. static BitmapPlatformDevice* Create(CGContextRef context, @@ -43,12 +42,12 @@ class BitmapPlatformDevice : public PlatformDevice, public SkDevice { // PlatformDevice overrides virtual CGContextRef GetBitmapContext(); virtual void DrawToNativeContext(CGContextRef context, int x, int y, - const CGRect* src_rect) OVERRIDE; - virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE; + const CGRect* src_rect); + virtual void MakeOpaque(int x, int y, int width, int height); // SkDevice overrides virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, - const SkClipStack&) OVERRIDE; + const SkClipStack&); protected: // Reference counted data that can be shared between multiple devices. This @@ -62,11 +61,11 @@ class BitmapPlatformDevice : public PlatformDevice, public SkDevice { // Flushes the CoreGraphics context so that the pixel data can be accessed // directly by Skia. Overridden from SkDevice, this is called when Skia // starts accessing pixel data. - virtual void onAccessBitmap(SkBitmap*) OVERRIDE; + virtual void onAccessBitmap(SkBitmap*); virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, int height, bool isOpaque, - Usage usage) OVERRIDE; + Usage usage); // Data associated with this device, guaranteed non-null. We hold a reference // to this object. diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc index 3a2a5b4..f1345fa 100644 --- a/skia/ext/bitmap_platform_device_win.cc +++ b/skia/ext/bitmap_platform_device_win.cc @@ -165,11 +165,10 @@ BitmapPlatformDevice* BitmapPlatformDevice::create(int width, BitmapPlatformDevice::BitmapPlatformDevice( BitmapPlatformDeviceData* data, const SkBitmap& bitmap) - : SkDevice(bitmap), + : PlatformDevice(bitmap), data_(data) { // The data object is already ref'ed for us by create(). SkDEBUGCODE(begin_paint_count_ = 0); - SetPlatformDevice(this, this); } BitmapPlatformDevice::~BitmapPlatformDevice() { @@ -263,3 +262,4 @@ SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( } } // namespace skia + diff --git a/skia/ext/bitmap_platform_device_win.h b/skia/ext/bitmap_platform_device_win.h index 5a5e466..270dc08 100644 --- a/skia/ext/bitmap_platform_device_win.h +++ b/skia/ext/bitmap_platform_device_win.h @@ -7,8 +7,7 @@ #pragma once #include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "skia/ext/platform_device.h" +#include "skia/ext/platform_device_win.h" namespace skia { @@ -26,7 +25,7 @@ namespace skia { // For us, that other bitmap will become invalid as soon as the device becomes // invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE // DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead. -class SK_API BitmapPlatformDevice : public PlatformDevice, public SkDevice { +class SK_API BitmapPlatformDevice : public PlatformDevice { public: // Factory function. The screen DC is used to create the bitmap, and will not // be stored beyond this function. is_opaque should be set if the caller @@ -35,11 +34,16 @@ class SK_API BitmapPlatformDevice : public PlatformDevice, public SkDevice { // The shared_section parameter is optional (pass NULL for default behavior). // If shared_section is non-null, then it must be a handle to a file-mapping // object returned by CreateFileMapping. See CreateDIBSection for details. - static BitmapPlatformDevice* create(HDC screen_dc, int width, int height, - bool is_opaque, HANDLE shared_section); + static BitmapPlatformDevice* create(HDC screen_dc, + int width, + int height, + bool is_opaque, + HANDLE shared_section); // This version is the same as above but will get the screen DC itself. - static BitmapPlatformDevice* create(int width, int height, bool is_opaque, + static BitmapPlatformDevice* create(int width, + int height, + bool is_opaque, HANDLE shared_section); virtual ~BitmapPlatformDevice(); @@ -47,27 +51,26 @@ class SK_API BitmapPlatformDevice : public PlatformDevice, public SkDevice { // PlatformDevice overrides // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The // bitmap DC is lazy created. - virtual PlatformSurface BeginPlatformPaint() OVERRIDE; - virtual void EndPlatformPaint() OVERRIDE; + virtual PlatformSurface BeginPlatformPaint(); + virtual void EndPlatformPaint(); - virtual void DrawToNativeContext(HDC dc, int x, int y, - const RECT* src_rect) OVERRIDE; - virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE; + virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect); + virtual void MakeOpaque(int x, int y, int width, int height); // Loads the given transform and clipping region into the HDC. This is // overridden from SkDevice. virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, - const SkClipStack&) OVERRIDE; + const SkClipStack&); protected: // Flushes the Windows device context so that the pixel data can be accessed // directly by Skia. Overridden from SkDevice, this is called when Skia // starts accessing pixel data. - virtual void onAccessBitmap(SkBitmap* bitmap) OVERRIDE; + virtual void onAccessBitmap(SkBitmap* bitmap); virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, int height, bool isOpaque, - Usage usage) OVERRIDE; + Usage usage); private: // Reference counted data that can be shared between multiple devices. This @@ -93,3 +96,4 @@ class SK_API BitmapPlatformDevice : public PlatformDevice, public SkDevice { } // namespace skia #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ + diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc index 9e1dde7..4bfde0f 100644 --- a/skia/ext/platform_device.cc +++ b/skia/ext/platform_device.cc @@ -27,12 +27,5 @@ PlatformDevice* GetPlatformDevice(SkDevice* device) { return NULL; } -bool PlatformDevice::IsNativeFontRenderingAllowed() { - return true; -} - -bool PlatformDevice::AlphaBlendUsed() const { - return false; -} - } // namespace skia + diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h index 55ef1f8..6b3afb1 100644 --- a/skia/ext/platform_device.h +++ b/skia/ext/platform_device.h @@ -6,28 +6,24 @@ #define SKIA_EXT_PLATFORM_DEVICE_H_ #pragma once -#include "build/build_config.h" +// This file provides an easy way to include the appropriate PlatformDevice +// header file for your platform. -#if defined(OS_WIN) +#if defined(WIN32) #include <windows.h> -#include <vector> #endif #include "third_party/skia/include/core/SkPreConfig.h" -#include "third_party/skia/include/core/SkDevice.h" #include "third_party/skia/include/core/SkColor.h" -class SkMatrix; -class SkPath; -class SkRegion; +class SkDevice; struct SkIRect; -#if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ - || defined(OS_SUN) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) typedef struct _cairo cairo_t; typedef struct _cairo_rectangle cairo_rectangle_t; -#elif defined(OS_MACOSX) +#elif defined(__APPLE__) typedef struct CGContext* CGContextRef; typedef struct CGRect CGRect; #endif @@ -36,14 +32,13 @@ namespace skia { class PlatformDevice; -#if defined(OS_WIN) +#if defined(WIN32) typedef HDC PlatformSurface; typedef RECT PlatformRect; -#elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ - || defined(OS_SUN) +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) typedef cairo_t* PlatformSurface; typedef cairo_rectangle_t PlatformRect; -#elif defined(OS_MACOSX) +#elif defined(__APPLE__) typedef CGContextRef PlatformSurface; typedef CGRect PlatformRect; #endif @@ -64,106 +59,15 @@ SK_API void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_device); SK_API PlatformDevice* GetPlatformDevice(SkDevice* device); +} // namespace skia -#if defined(OS_WIN) -// Initializes the default settings and colors in a device context. -SK_API void InitializeDC(HDC context); -#elif defined (OS_MACOSX) -// Returns the CGContext that backing the SkDevice. Forwards to the bound -// PlatformDevice. Returns NULL if no PlatformDevice is bound. -SK_API CGContextRef GetBitmapContext(SkDevice* device); -#endif - -// A SkDevice is basically a wrapper around SkBitmap that provides a surface for -// SkCanvas to draw into. PlatformDevice provides a surface Windows can also -// write to. It also provides functionality to play well with GDI drawing -// functions. This class is abstract and must be subclassed. It provides the -// basic interface to implement it either with or without a bitmap backend. -// -// PlatformDevice provides an interface which sub-classes of SkDevice can also -// provide to allow for drawing by the native platform into the device. -class SK_API PlatformDevice { - public: - virtual ~PlatformDevice() {} - -#if defined(OS_MACOSX) - // The CGContext that corresponds to the bitmap, used for CoreGraphics - // operations drawing into the bitmap. This is possibly heavyweight, so it - // should exist only during one pass of rendering. - virtual CGContextRef GetBitmapContext() = 0; -#endif - - // The DC that corresponds to the bitmap, used for GDI operations drawing - // into the bitmap. This is possibly heavyweight, so it should be existant - // only during one pass of rendering. - virtual PlatformSurface BeginPlatformPaint(); - - // Finish a previous call to beginPlatformPaint. - virtual void EndPlatformPaint(); - - // Draws to the given screen DC, if the bitmap DC doesn't exist, this will - // temporarily create it. However, if you have created the bitmap DC, it will - // be more efficient if you don't free it until after this call so it doesn't - // have to be created twice. If src_rect is null, then the entirety of the - // source device will be copied. - virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, - const PlatformRect* src_rect) = 0; - - // Sets the opacity of each pixel in the specified region to be opaque. - virtual void MakeOpaque(int x, int y, int width, int height) { } - - // Returns if GDI is allowed to render text to this device. - virtual bool IsNativeFontRenderingAllowed(); - - // True if AlphaBlend() was called during a - // BeginPlatformPaint()/EndPlatformPaint() pair. - // Used by the printing subclasses. See |VectorPlatformDeviceEmf|. - virtual bool AlphaBlendUsed() const; - -#if defined(OS_WIN) - // Loads a SkPath into the GDI context. The path can there after be used for - // clipping or as a stroke. Returns false if the path failed to be loaded. - static bool LoadPathToDC(HDC context, const SkPath& path); - - // Loads a SkRegion into the GDI context. - static void LoadClippingRegionToDC(HDC context, const SkRegion& region, - const SkMatrix& transformation); -#elif defined(OS_MACOSX) - // Loads a SkPath into the CG context. The path can there after be used for - // clipping or as a stroke. - static void LoadPathToCGContext(CGContextRef context, const SkPath& path); - - // Initializes the default settings and colors in a device context. - static void InitializeCGContext(CGContextRef context); - - // Loads a SkRegion into the CG context. - static void LoadClippingRegionToCGContext(CGContextRef context, - const SkRegion& region, - const SkMatrix& transformation); -#endif - - protected: -#if defined(OS_WIN) - // Arrays must be inside structures. - struct CubicPoints { - SkPoint p[4]; - }; - typedef std::vector<CubicPoints> CubicPath; - typedef std::vector<CubicPath> CubicPaths; - - // Loads the specified Skia transform into the device context, excluding - // perspective (which GDI doesn't support). - static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); - - // Transforms SkPath's paths into a series of cubic path. - static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); -#elif defined(OS_MACOSX) - // Loads the specified Skia transform into the device context - static void LoadTransformToCGContext(CGContextRef context, - const SkMatrix& matrix); +#if defined(WIN32) +#include "skia/ext/platform_device_win.h" +#elif defined(__APPLE__) +#include "skia/ext/platform_device_mac.h" +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__sun) +#include "skia/ext/platform_device_linux.h" #endif -}; - -} // namespace skia #endif diff --git a/skia/ext/platform_device_linux.cc b/skia/ext/platform_device_linux.cc index f72e614..f633758 100644 --- a/skia/ext/platform_device_linux.cc +++ b/skia/ext/platform_device_linux.cc @@ -6,12 +6,23 @@ namespace skia { -PlatformSurface PlatformDevice::BeginPlatformPaint() { - return NULL; +PlatformDevice::PlatformDevice(const SkBitmap& bitmap) + : SkDevice(bitmap) { + SetPlatformDevice(this, this); +} + +bool PlatformDevice::IsNativeFontRenderingAllowed() { + return true; } void PlatformDevice::EndPlatformPaint() { // We don't need to do anything on Linux here. } +void PlatformDevice::DrawToNativeContext(PlatformSurface surface, int x, int y, + const PlatformRect* src_rect) { + // Should never be called on Linux. + SkASSERT(false); +} + } // namespace skia diff --git a/skia/ext/platform_device_linux.h b/skia/ext/platform_device_linux.h new file mode 100644 index 0000000..51c292f --- /dev/null +++ b/skia/ext/platform_device_linux.h @@ -0,0 +1,38 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SKIA_EXT_PLATFORM_DEVICE_LINUX_H_ +#define SKIA_EXT_PLATFORM_DEVICE_LINUX_H_ +#pragma once + +#include "skia/ext/platform_device.h" +#include "third_party/skia/include/core/SkDevice.h" + +namespace skia { + +// Blindly copying the mac hierarchy. +class PlatformDevice : public SkDevice { + public: + typedef cairo_t* PlatformSurface; + + // Returns if native platform APIs are allowed to render text to this device. + virtual bool IsNativeFontRenderingAllowed(); + + virtual PlatformSurface BeginPlatformPaint() = 0; + virtual void EndPlatformPaint(); + + virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, + const PlatformRect* src_rect ); + + // Sets the opacity of each pixel in the specified region to be opaque. + virtual void MakeOpaque(int x, int y, int width, int height) { } + + protected: + // Forwards |bitmap| to SkDevice's constructor. + explicit PlatformDevice(const SkBitmap& bitmap); +}; + +} // namespace skia + +#endif // SKIA_EXT_PLATFORM_DEVICE_LINUX_H_ diff --git a/skia/ext/platform_device_mac.cc b/skia/ext/platform_device_mac.cc index 6ff017d..9d2695f 100644 --- a/skia/ext/platform_device_mac.cc +++ b/skia/ext/platform_device_mac.cc @@ -22,6 +22,15 @@ CGContextRef GetBitmapContext(SkDevice* device) { return NULL; } +PlatformDevice::PlatformDevice(const SkBitmap& bitmap) + : SkDevice(bitmap) { + SetPlatformDevice(this, this); +} + +bool PlatformDevice::IsNativeFontRenderingAllowed() { + return true; +} + CGContextRef PlatformDevice::BeginPlatformPaint() { return GetBitmapContext(); } @@ -153,3 +162,4 @@ void PlatformDevice::LoadClippingRegionToCGContext( } } // namespace skia + diff --git a/skia/ext/platform_device_mac.h b/skia/ext/platform_device_mac.h new file mode 100644 index 0000000..610f07f --- /dev/null +++ b/skia/ext/platform_device_mac.h @@ -0,0 +1,80 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SKIA_EXT_PLATFORM_DEVICE_MAC_H_ +#define SKIA_EXT_PLATFORM_DEVICE_MAC_H_ +#pragma once + +#include "third_party/skia/include/core/SkDevice.h" + +typedef struct CGContext* CGContextRef; +typedef struct CGRect CGRect; + +class SkMatrix; +class SkPath; +class SkRegion; + +namespace skia { + +// Returns the CGContext that backing the SkDevice. Forwards to the bound +// PlatformDevice. Returns NULL if no PlatformDevice is bound. +SK_API CGContextRef GetBitmapContext(SkDevice* device); + +// A device is basically a wrapper around SkBitmap that provides a surface for +// SkCanvas to draw into. Our device provides a surface CoreGraphics can also +// write to. It also provides functionality to play well with CG drawing +// functions. +// This class is abstract and must be subclassed. It provides the basic +// interface to implement it either with or without a bitmap backend. +class PlatformDevice : public SkDevice { + public: + typedef CGContextRef PlatformSurface; + + // The CGContext that corresponds to the bitmap, used for CoreGraphics + // operations drawing into the bitmap. This is possibly heavyweight, so it + // should exist only during one pass of rendering. + virtual CGContextRef GetBitmapContext() = 0; + + // Draws to the given graphics context. If the bitmap context doesn't exist, + // this will temporarily create it. However, if you have created the bitmap + // context, it will be more efficient if you don't free it until after this + // call so it doesn't have to be created twice. If src_rect is null, then + // the entirety of the source device will be copied. + virtual void DrawToNativeContext(CGContextRef context, int x, int y, + const CGRect* src_rect) = 0; + + // Sets the opacity of each pixel in the specified region to be opaque. + virtual void MakeOpaque(int x, int y, int width, int height) { } + + // Returns if native platform APIs are allowed to render text to this device. + virtual bool IsNativeFontRenderingAllowed(); + + virtual PlatformSurface BeginPlatformPaint(); + virtual void EndPlatformPaint(); + + // Initializes the default settings and colors in a device context. + static void InitializeCGContext(CGContextRef context); + + // Loads a SkPath into the CG context. The path can there after be used for + // clipping or as a stroke. + static void LoadPathToCGContext(CGContextRef context, const SkPath& path); + + // Loads a SkRegion into the CG context. + static void LoadClippingRegionToCGContext(CGContextRef context, + const SkRegion& region, + const SkMatrix& transformation); + + protected: + // Forwards |bitmap| to SkDevice's constructor. + PlatformDevice(const SkBitmap& bitmap); + + // Loads the specified Skia transform into the device context + static void LoadTransformToCGContext(CGContextRef context, + const SkMatrix& matrix); +}; + +} // namespace skia + +#endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_ + diff --git a/skia/ext/platform_device_win.cc b/skia/ext/platform_device_win.cc index 100a811..ea72165 100644 --- a/skia/ext/platform_device_win.cc +++ b/skia/ext/platform_device_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -51,8 +51,9 @@ void InitializeDC(HDC context) { SkASSERT(res != 0); } -PlatformSurface PlatformDevice::BeginPlatformPaint() { - return 0; +PlatformDevice::PlatformDevice(const SkBitmap& bitmap) + : SkDevice(bitmap) { + SetPlatformDevice(this, this); } void PlatformDevice::EndPlatformPaint() { @@ -60,10 +61,6 @@ void PlatformDevice::EndPlatformPaint() { // Flushing will be done in onAccessBitmap. } -void PlatformDevice::DrawToNativeContext(PlatformSurface surface, int x, int y, - const PlatformRect* src_rect) { -} - // static bool PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) { switch (path.getFillType()) { @@ -236,3 +233,4 @@ void PlatformDevice::LoadClippingRegionToDC(HDC context, } } // namespace skia + diff --git a/skia/ext/platform_device_win.h b/skia/ext/platform_device_win.h new file mode 100644 index 0000000..f21ca1f --- /dev/null +++ b/skia/ext/platform_device_win.h @@ -0,0 +1,90 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SKIA_EXT_PLATFORM_DEVICE_WIN_H_ +#define SKIA_EXT_PLATFORM_DEVICE_WIN_H_ +#pragma once + +#include <windows.h> + +#include <vector> + +#include "third_party/skia/include/core/SkDevice.h" + +class SkMatrix; +class SkPath; +class SkRegion; + +namespace skia { + +// Initializes the default settings and colors in a device context. +SK_API void InitializeDC(HDC context); + +// A device is basically a wrapper around SkBitmap that provides a surface for +// SkCanvas to draw into. Our device provides a surface Windows can also write +// to. It also provides functionality to play well with GDI drawing functions. +// This class is abstract and must be subclassed. It provides the basic +// interface to implement it either with or without a bitmap backend. +class SK_API PlatformDevice : public SkDevice { + public: + typedef HDC PlatformSurface; + + // The DC that corresponds to the bitmap, used for GDI operations drawing + // into the bitmap. This is possibly heavyweight, so it should be existant + // only during one pass of rendering. + virtual PlatformSurface BeginPlatformPaint() = 0; + + // Finish a previous call to beginPlatformPaint. + virtual void EndPlatformPaint(); + + // Draws to the given screen DC, if the bitmap DC doesn't exist, this will + // temporarily create it. However, if you have created the bitmap DC, it will + // be more efficient if you don't free it until after this call so it doesn't + // have to be created twice. If src_rect is null, then the entirety of the + // source device will be copied. + virtual void DrawToNativeContext(HDC dc, int x, int y, + const RECT* src_rect) = 0; + + // Sets the opacity of each pixel in the specified region to be opaque. + virtual void MakeOpaque(int x, int y, int width, int height) { } + + // Returns if GDI is allowed to render text to this device. + virtual bool IsNativeFontRenderingAllowed() { return true; } + + // True if AlphaBlend() was called during a + // BeginPlatformPaint()/EndPlatformPaint() pair. + // Used by the printing subclasses. See |VectorPlatformDeviceEmf|. + virtual bool AlphaBlendUsed() const { return false; } + + // Loads a SkPath into the GDI context. The path can there after be used for + // clipping or as a stroke. Returns false if the path failed to be loaded. + static bool LoadPathToDC(HDC context, const SkPath& path); + + // Loads a SkRegion into the GDI context. + static void LoadClippingRegionToDC(HDC context, const SkRegion& region, + const SkMatrix& transformation); + + protected: + // Arrays must be inside structures. + struct CubicPoints { + SkPoint p[4]; + }; + typedef std::vector<CubicPoints> CubicPath; + typedef std::vector<CubicPath> CubicPaths; + + // Forwards |bitmap| to SkDevice's constructor. + PlatformDevice(const SkBitmap& bitmap); + + // Loads the specified Skia transform into the device context, excluding + // perspective (which GDI doesn't support). + static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); + + // Transforms SkPath's paths into a series of cubic path. + static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); +}; + +} // namespace skia + +#endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_ + diff --git a/skia/ext/vector_platform_device_cairo_linux.cc b/skia/ext/vector_platform_device_cairo_linux.cc index 1d31cf6..f4a4e0b 100644 --- a/skia/ext/vector_platform_device_cairo_linux.cc +++ b/skia/ext/vector_platform_device_cairo_linux.cc @@ -69,8 +69,9 @@ bool IsContextValid(cairo_t* context) { namespace skia { // static -SkDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context, int width, - int height, bool isOpaque) { +PlatformDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context, + int width, int height, + bool isOpaque) { // TODO(myhuang): Here we might also have similar issues as those on Windows // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). // Please note that is_opaque is true when we use this class for printing. @@ -91,12 +92,10 @@ SkDevice* VectorPlatformDeviceCairo::CreateDevice(cairo_t* context, int width, VectorPlatformDeviceCairo::VectorPlatformDeviceCairo(PlatformSurface context, const SkBitmap& bitmap) - : SkDevice(bitmap), + : PlatformDevice(bitmap), context_(context) { SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); - SetPlatformDevice(this, this); - // Increase the reference count to keep the context alive. cairo_reference(context_); @@ -108,16 +107,11 @@ VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() { cairo_destroy(context_); } -PlatformSurface VectorPlatformDeviceCairo::BeginPlatformPaint() { +PlatformDevice::PlatformSurface +VectorPlatformDeviceCairo::BeginPlatformPaint() { return context_; } -void VectorPlatformDeviceCairo::DrawToNativeContext( - PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { - // Should never be called on Linux. - SkASSERT(false); -} - SkDevice* VectorPlatformDeviceCairo::onCreateCompatibleDevice( SkBitmap::Config config, int width, int height, diff --git a/skia/ext/vector_platform_device_cairo_linux.h b/skia/ext/vector_platform_device_cairo_linux.h index 36be0c76..72a90f6 100644 --- a/skia/ext/vector_platform_device_cairo_linux.h +++ b/skia/ext/vector_platform_device_cairo_linux.h @@ -19,13 +19,12 @@ namespace skia { // cooresponding Cairo APIs and outputs to a Cairo surface. Please NOTE that // since it is completely vectorial, the bitmap content in it is thus // meaningless. -class SK_API VectorPlatformDeviceCairo : public PlatformDevice, - public SkDevice { +class SK_API VectorPlatformDeviceCairo : public PlatformDevice { public: virtual ~VectorPlatformDeviceCairo(); - static SkDevice* CreateDevice(cairo_t* context, int width, int height, - bool isOpaque); + static PlatformDevice* CreateDevice(cairo_t* context, int width, int height, + bool isOpaque); // Clean up cached fonts. It is an error to call this while some // VectorPlatformDeviceCairo callee is still using fonts created for it by @@ -68,19 +67,17 @@ class SK_API VectorPlatformDeviceCairo : public PlatformDevice, const SkPaint&) OVERRIDE; virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, - const SkClipStack&) OVERRIDE; + const SkClipStack&); // Overridden from PlatformDevice - virtual PlatformSurface BeginPlatformPaint() OVERRIDE; - virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, - const PlatformRect* src_rect) OVERRIDE; + virtual PlatformSurface BeginPlatformPaint(); protected: VectorPlatformDeviceCairo(PlatformSurface context, const SkBitmap& bitmap); virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, int height, bool isOpaque, - Usage usage) OVERRIDE; + Usage usage); private: // Apply paint's color in the context. diff --git a/skia/ext/vector_platform_device_emf_win.cc b/skia/ext/vector_platform_device_emf_win.cc index 9741a83..eac7977 100644 --- a/skia/ext/vector_platform_device_emf_win.cc +++ b/skia/ext/vector_platform_device_emf_win.cc @@ -15,8 +15,9 @@ namespace skia { //static -SkDevice* VectorPlatformDeviceEmf::CreateDevice( - int width, int height, bool is_opaque, HANDLE shared_section) { +PlatformDevice* VectorPlatformDeviceEmf::CreateDevice(int width, int height, + bool is_opaque, + HANDLE shared_section) { if (!is_opaque) { // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent // layer, i.e. merging it, we need to rasterize it because GDI doesn't @@ -39,7 +40,7 @@ SkDevice* VectorPlatformDeviceEmf::CreateDevice( // SkScalarRound(value) as SkScalarRound(value * 10). Safari is already // doing the same for text rendering. SkASSERT(shared_section); - SkDevice* device = VectorPlatformDeviceEmf::create( + PlatformDevice* device = VectorPlatformDeviceEmf::create( reinterpret_cast<HDC>(shared_section), width, height); return device; } @@ -58,7 +59,9 @@ static void FillBitmapInfoHeader(int width, int height, BITMAPINFOHEADER* hdr) { hdr->biClrImportant = 0; } -SkDevice* VectorPlatformDeviceEmf::create(HDC dc, int width, int height) { +VectorPlatformDeviceEmf* VectorPlatformDeviceEmf::create(HDC dc, + int width, + int height) { InitializeDC(dc); // Link the SkBitmap to the current selected bitmap in the device context. @@ -93,13 +96,12 @@ SkDevice* VectorPlatformDeviceEmf::create(HDC dc, int width, int height) { } VectorPlatformDeviceEmf::VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap) - : SkDevice(bitmap), + : PlatformDevice(bitmap), hdc_(dc), previous_brush_(NULL), previous_pen_(NULL), alpha_blend_used_(false) { transform_.reset(); - SetPlatformDevice(this, this); } VectorPlatformDeviceEmf::~VectorPlatformDeviceEmf() { @@ -863,3 +865,4 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, } } // namespace skia + diff --git a/skia/ext/vector_platform_device_emf_win.h b/skia/ext/vector_platform_device_emf_win.h index 1d7e5a9a..61283ff 100644 --- a/skia/ext/vector_platform_device_emf_win.h +++ b/skia/ext/vector_platform_device_emf_win.h @@ -18,13 +18,14 @@ namespace skia { // SkCanvas to draw into. This specific device is not not backed by a surface // and is thus unreadable. This is because the backend is completely vectorial. // This device is a simple wrapper over a Windows device context (HDC) handle. -class VectorPlatformDeviceEmf : public PlatformDevice, public SkDevice { +class VectorPlatformDeviceEmf : public PlatformDevice { public: - SK_API static SkDevice* CreateDevice(int width, int height, bool isOpaque, - HANDLE shared_section); + SK_API static PlatformDevice* CreateDevice(int width, int height, + bool isOpaque, + HANDLE shared_section); // Factory function. The DC is kept as the output context. - static SkDevice* create(HDC dc, int width, int height); + static VectorPlatformDeviceEmf* create(HDC dc, int width, int height); VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap); virtual ~VectorPlatformDeviceEmf(); @@ -136,3 +137,4 @@ class VectorPlatformDeviceEmf : public PlatformDevice, public SkDevice { } // namespace skia #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ + diff --git a/skia/ext/vector_platform_device_skia.cc b/skia/ext/vector_platform_device_skia.cc index a320526..0971d1a 100644 --- a/skia/ext/vector_platform_device_skia.cc +++ b/skia/ext/vector_platform_device_skia.cc @@ -19,12 +19,9 @@ static inline SkBitmap makeABitmap(int width, int height) { return bitmap; } -VectorPlatformDeviceSkia::VectorPlatformDeviceSkia( - const SkISize& pageSize, - const SkISize& contentSize, - const SkMatrix& initialTransform) - : SkPDFDevice(pageSize, contentSize, initialTransform) { - SetPlatformDevice(this, this); +VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(SkPDFDevice* pdf_device) + : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), + pdf_device_(pdf_device) { } VectorPlatformDeviceSkia::~VectorPlatformDeviceSkia() { @@ -34,7 +31,7 @@ bool VectorPlatformDeviceSkia::IsNativeFontRenderingAllowed() { return false; } -PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() { +PlatformDevice::PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() { // Even when drawing a vector representation of the page, we have to // provide a raster surface for plugins to render into - they don't have // a vector interface. Therefore we create a BitmapPlatformDevice here @@ -42,13 +39,13 @@ PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() { // image in EndPlatformPaint. DCHECK(raster_surface_ == NULL); #if defined(OS_WIN) - raster_surface_ = BitmapPlatformDevice::create(width(), - height(), + raster_surface_ = BitmapPlatformDevice::create(pdf_device_->width(), + pdf_device_->height(), false, /* not opaque */ NULL); #elif defined(OS_POSIX) && !defined(OS_MACOSX) - raster_surface_ = BitmapPlatformDevice::Create(width(), - height(), + raster_surface_ = BitmapPlatformDevice::Create(pdf_device_->width(), + pdf_device_->height(), false /* not opaque */); #endif raster_surface_->unref(); // SkRefPtr and create both took a reference. @@ -63,14 +60,143 @@ void VectorPlatformDeviceSkia::EndPlatformPaint() { // SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake // it out by setting a non-empty clip. SkDraw draw; - SkRegion clip(SkIRect::MakeWH(width(), height())); + SkRegion clip(SkIRect::MakeWH(pdf_device_->width(), pdf_device_->height())); draw.fClip=&clip; - drawSprite(draw, raster_surface_->accessBitmap(false), 0, 0, paint); + pdf_device_->drawSprite(draw, raster_surface_->accessBitmap(false), 0, 0, + paint); // BitmapPlatformDevice matches begin and end calls. raster_surface_->EndPlatformPaint(); raster_surface_ = NULL; } +uint32_t VectorPlatformDeviceSkia::getDeviceCapabilities() { + return SkDevice::getDeviceCapabilities() | kVector_Capability; +} + +int VectorPlatformDeviceSkia::width() const { + return pdf_device_->width(); +} + +int VectorPlatformDeviceSkia::height() const { + return pdf_device_->height(); +} + +void VectorPlatformDeviceSkia::setMatrixClip(const SkMatrix& matrix, + const SkRegion& region, + const SkClipStack& stack) { + pdf_device_->setMatrixClip(matrix, region, stack); +} + +bool VectorPlatformDeviceSkia::readPixels(const SkIRect& srcRect, + SkBitmap* bitmap) { + return false; +} + +void VectorPlatformDeviceSkia::drawPaint(const SkDraw& draw, + const SkPaint& paint) { + pdf_device_->drawPaint(draw, paint); +} + +void VectorPlatformDeviceSkia::drawPoints(const SkDraw& draw, + SkCanvas::PointMode mode, + size_t count, const SkPoint pts[], + const SkPaint& paint) { + pdf_device_->drawPoints(draw, mode, count, pts, paint); +} + +void VectorPlatformDeviceSkia::drawRect(const SkDraw& draw, + const SkRect& rect, + const SkPaint& paint) { + pdf_device_->drawRect(draw, rect, paint); +} + +void VectorPlatformDeviceSkia::drawPath(const SkDraw& draw, + const SkPath& path, + const SkPaint& paint, + const SkMatrix* prePathMatrix, + bool pathIsMutable) { + pdf_device_->drawPath(draw, path, paint, prePathMatrix, pathIsMutable); +} + +void VectorPlatformDeviceSkia::drawBitmap(const SkDraw& draw, + const SkBitmap& bitmap, + const SkIRect* srcRectOrNull, + const SkMatrix& matrix, + const SkPaint& paint) { + pdf_device_->drawBitmap(draw, bitmap, srcRectOrNull, matrix, paint); +} + +void VectorPlatformDeviceSkia::drawSprite(const SkDraw& draw, + const SkBitmap& bitmap, + int x, int y, + const SkPaint& paint) { + pdf_device_->drawSprite(draw, bitmap, x, y, paint); +} + +void VectorPlatformDeviceSkia::drawText(const SkDraw& draw, + const void* text, + size_t byteLength, + SkScalar x, + SkScalar y, + const SkPaint& paint) { + pdf_device_->drawText(draw, text, byteLength, x, y, paint); +} + +void VectorPlatformDeviceSkia::drawPosText(const SkDraw& draw, + const void* text, + size_t len, + const SkScalar pos[], + SkScalar constY, + int scalarsPerPos, + const SkPaint& paint) { + pdf_device_->drawPosText(draw, text, len, pos, constY, scalarsPerPos, paint); +} + +void VectorPlatformDeviceSkia::drawTextOnPath(const SkDraw& draw, + const void* text, + size_t len, + const SkPath& path, + const SkMatrix* matrix, + const SkPaint& paint) { + pdf_device_->drawTextOnPath(draw, text, len, path, matrix, paint); +} + +void VectorPlatformDeviceSkia::drawVertices(const SkDraw& draw, + SkCanvas::VertexMode vmode, + int vertexCount, + const SkPoint vertices[], + const SkPoint texs[], + const SkColor colors[], + SkXfermode* xmode, + const uint16_t indices[], + int indexCount, + const SkPaint& paint) { + pdf_device_->drawVertices(draw, vmode, vertexCount, vertices, texs, colors, + xmode, indices, indexCount, paint); +} + +void VectorPlatformDeviceSkia::drawDevice(const SkDraw& draw, + SkDevice* device, + int x, + int y, + const SkPaint& paint) { + SkDevice* real_device = device; + if ((device->getDeviceCapabilities() & kVector_Capability)) { + // Assume that a vectorial device means a VectorPlatformDeviceSkia, we need + // to unwrap the embedded SkPDFDevice. + VectorPlatformDeviceSkia* vector_device = + static_cast<VectorPlatformDeviceSkia*>(device); + vector_device->pdf_device_->setOrigin(vector_device->getOrigin().fX, + vector_device->getOrigin().fY); + real_device = vector_device->pdf_device_.get(); + } + pdf_device_->drawDevice(draw, real_device, x, y, paint); +} + +void VectorPlatformDeviceSkia::setDrawingArea(SkPDFDevice::DrawingArea area) { + pdf_device_->setDrawingArea(area); +} + #if defined(OS_WIN) void VectorPlatformDeviceSkia::DrawToNativeContext(HDC dc, int x, @@ -88,12 +214,16 @@ CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { SkASSERT(false); return NULL; } -#elif defined(OS_LINUX) -void VectorPlatformDeviceSkia::DrawToNativeContext( - PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { - // Should never be called on Linux. - SkASSERT(false); -} + #endif +SkDevice* VectorPlatformDeviceSkia::onCreateCompatibleDevice( + SkBitmap::Config config, int width, int height, bool isOpaque, + Usage /*usage*/) { + SkAutoTUnref<SkDevice> dev(pdf_device_->createCompatibleDevice(config, width, + height, + isOpaque)); + return new VectorPlatformDeviceSkia(static_cast<SkPDFDevice*>(dev.get())); +} + } // namespace skia diff --git a/skia/ext/vector_platform_device_skia.h b/skia/ext/vector_platform_device_skia.h index 005d798..238996b 100644 --- a/skia/ext/vector_platform_device_skia.h +++ b/skia/ext/vector_platform_device_skia.h @@ -22,13 +22,13 @@ namespace skia { class BitmapPlatformDevice; -class VectorPlatformDeviceSkia : public PlatformDevice, public SkPDFDevice { +class VectorPlatformDeviceSkia : public PlatformDevice { public: - SK_API VectorPlatformDeviceSkia(const SkISize& pageSize, - const SkISize& contentSize, - const SkMatrix& initialTransform); + SK_API VectorPlatformDeviceSkia(SkPDFDevice* pdf_device); virtual ~VectorPlatformDeviceSkia(); + SkPDFDevice* PdfDevice() { return pdf_device_.get(); } + // PlatformDevice methods. virtual bool IsNativeFontRenderingAllowed(); @@ -40,12 +40,56 @@ class VectorPlatformDeviceSkia : public PlatformDevice, public SkPDFDevice { virtual void DrawToNativeContext(CGContext* context, int x, int y, const CGRect* src_rect); virtual CGContextRef GetBitmapContext(); -#elif defined(OS_LINUX) - virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, - const PlatformRect* src_rect); #endif + // SkDevice methods. + virtual uint32_t getDeviceCapabilities(); + virtual int width() const; + virtual int height() const; + virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& region, + const SkClipStack& stack); + virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); + + virtual void drawPaint(const SkDraw& draw, const SkPaint& paint); + virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, + size_t count, const SkPoint[], const SkPaint& paint); + virtual void drawRect(const SkDraw& draw, const SkRect& rect, + const SkPaint& paint); + virtual void drawPath(const SkDraw& draw, const SkPath& path, + const SkPaint& paint, const SkMatrix* prePathMatrix, + bool pathIsMutable); + virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, + const SkIRect* srcRectOrNull, const SkMatrix& matrix, + const SkPaint& paint); + virtual void drawSprite(const SkDraw& draw, const SkBitmap& bitmap, + int x, int y, const SkPaint& paint); + virtual void drawText(const SkDraw& draw, const void* text, size_t len, + SkScalar x, SkScalar y, const SkPaint& paint); + virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, + const SkScalar pos[], SkScalar constY, + int scalarsPerPos, const SkPaint& paint); + virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len, + const SkPath& path, const SkMatrix* matrix, + const SkPaint& paint); + virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, + int vertexCount, const SkPoint verts[], + const SkPoint texs[], const SkColor colors[], + SkXfermode* xmode, const uint16_t indices[], + int indexCount, const SkPaint& paint); + virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, + const SkPaint&); + + // Sets the drawing area for the device. Subsequent draw calls are + // directed to the specific drawing area (margin or content area). + SK_API void setDrawingArea(SkPDFDevice::DrawingArea area); + + protected: + virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, + int height, bool isOpaque, + Usage usage); + private: + SkRefPtr<SkPDFDevice> pdf_device_; SkRefPtr<BitmapPlatformDevice> raster_surface_; DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceSkia); diff --git a/skia/skia.gyp b/skia/skia.gyp index f83c360..076df75 100644 --- a/skia/skia.gyp +++ b/skia/skia.gyp @@ -685,8 +685,11 @@ 'ext/platform_device.cc', 'ext/platform_device.h', 'ext/platform_device_linux.cc', + 'ext/platform_device_linux.h', 'ext/platform_device_mac.cc', + 'ext/platform_device_mac.h', 'ext/platform_device_win.cc', + 'ext/platform_device_win.h', 'ext/SkMemory_new_handler.cpp', 'ext/skia_utils_mac.mm', 'ext/skia_utils_mac.h', |