diff options
author | twiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 15:53:12 +0000 |
---|---|---|
committer | twiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 15:53:12 +0000 |
commit | e414727ea30e03a5d4582bdbba42d67327605273 (patch) | |
tree | 58746c063aea418e36d5a618c67bdf1bec9e7409 /skia/ext/platform_device.h | |
parent | 33986d3ecde79d6a1bdf2b0edd17fc13bc2cc78b (diff) | |
download | chromium_src-e414727ea30e03a5d4582bdbba42d67327605273.zip chromium_src-e414727ea30e03a5d4582bdbba42d67327605273.tar.gz chromium_src-e414727ea30e03a5d4582bdbba42d67327605273.tar.bz2 |
This change implements a first pass in the effort to remove the dependency of PlatformDevice within Chrome. The Skia library now provides multiple back-ends for the SkDevice class, so PlatformDevice's inheritance of SkDevice, and the assumption of instances of PlatformDevice limits the use of these new back-ends.
A new set of helper functions is provided for the PlatformDevice entry points. Upon construction of a PlatformDevice, a pointer to the interface is cached in the parent SkDevice's SkMetaData. The new helper functions forward calls to the interface cached in the metadata.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/7019013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/platform_device.h')
-rw-r--r-- | skia/ext/platform_device.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h index 971c0a7..4f876d9 100644 --- a/skia/ext/platform_device.h +++ b/skia/ext/platform_device.h @@ -10,6 +10,81 @@ // header file for your platform. #if defined(WIN32) +#include <windows.h> +#endif + +#include "third_party/skia/include/core/SkPreConfig.h" +#include "third_party/skia/include/core/SkColor.h" + + +class SkDevice; +struct SkIRect; + +#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) +typedef struct _cairo cairo_t; +typedef struct _cairo_rectangle cairo_rectangle_t; +#elif defined(__APPLE__) +typedef struct CGContext* CGContextRef; +typedef struct CGRect CGRect; +#endif + +namespace skia { + +class PlatformDevice; + +#if defined(WIN32) +typedef HDC PlatformSurface; +typedef RECT PlatformRect; +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) +typedef cairo_t* PlatformSurface; +typedef cairo_rectangle_t PlatformRect; +#elif defined(__APPLE__) +typedef CGContextRef PlatformSurface; +typedef CGRect PlatformRect; +#endif + +// The following routines provide accessor points for the functionality +// exported by the various PlatformDevice ports. The PlatformDevice, and +// BitmapPlatformDevice classes inherit directly from SkDevice, which is no +// longer a supported usage-pattern for skia. In preparation of the removal of +// these classes, all calls to PlatformDevice::* should be routed through these +// helper functions. + +// Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent +// calls to the functions exported below will forward the request to the +// corresponding method on the bound PlatformDevice instance. If no +// PlatformDevice has been bound to the SkDevice passed, then the routines are +// NOPS. +SK_API void SetPlatformDevice(SkDevice* device, + PlatformDevice* platform_device); +SK_API PlatformDevice* GetPlatformDevice(SkDevice* device); + +// Returns if the preferred rendering engine is vectorial or bitmap based. +// Forwards to PlatformDevice::IsVectorial, if a PlatformDevice is bound, +// otherwise falls-back to the SkDevice::getDeviceCapabilities routine. +SK_API bool IsVectorial(SkDevice* device); + +// Returns if the native font rendering engine is allowed to render text to +// this device. +SK_API bool IsNativeFontRenderingAllowed(SkDevice* device); + +// Returns the PlatformSurface used for native rendering into the device. +SK_API PlatformSurface BeginPlatformPaint(SkDevice* device); + +// Finish a previous call to BeginPlatformPaint. +SK_API void EndPlatformPaint(SkDevice* device); + +// Draws to the given PlatformSurface, |context|. Forwards to the +// PlatformDevice bound to |device|. Otherwise is a NOP. +SK_API void DrawToNativeContext(SkDevice* device, PlatformSurface context, + int x, int y, const PlatformRect* src_rect); + +// Sets the opacity of each pixel in the specified region to be opaque. +SK_API void MakeOpaque(SkDevice* device, int x, int y, int width, int height); + +} // namespace skia + +#if defined(WIN32) #include "skia/ext/platform_device_win.h" #elif defined(__APPLE__) #include "skia/ext/platform_device_mac.h" |