diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 22:44:07 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 22:44:07 +0000 |
commit | 9abceb78361ca70703fdf6051eb4e556f06f2b6a (patch) | |
tree | 2906b780dc22793414466f83e7d050af2e0d638e /skia/ext/bitmap_platform_device_cairo.h | |
parent | fbc94488149d051eb37f09e9e5ba546f9d18880e (diff) | |
download | chromium_src-9abceb78361ca70703fdf6051eb4e556f06f2b6a.zip chromium_src-9abceb78361ca70703fdf6051eb4e556f06f2b6a.tar.gz chromium_src-9abceb78361ca70703fdf6051eb4e556f06f2b6a.tar.bz2 |
Remove BitmapPlatformDeviceData, and merge its functionality into the appropriate BitmapPlatformDevice. It was a little twisty maze of #ifdefs, ostensibly created to allow successful assignment and copy construction of the device. However, I could not find any such use, and the BitmapPlatformDevices are all marked DISALLOW_COPY_AND_ASSIGN!
Instead, we use a subclass of SkPixelRef to handle ownership of the platform-specific bitmaps. This allows correct Skia semantics: the SkBitmap used for device drawing can safely outlive the device, since it is refcounted. Such a subclass already existed for Windows; this simply implements it for Cairo as well, and uses it in all cases.
TBR=brettw
Review URL: https://codereview.chromium.org/95773002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/bitmap_platform_device_cairo.h')
-rw-r--r-- | skia/ext/bitmap_platform_device_cairo.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/skia/ext/bitmap_platform_device_cairo.h b/skia/ext/bitmap_platform_device_cairo.h index 914be34..5b3c46c 100644 --- a/skia/ext/bitmap_platform_device_cairo.h +++ b/skia/ext/bitmap_platform_device_cairo.h @@ -57,9 +57,6 @@ namespace skia { // case we'll probably create the buffer from a precreated region of memory. // ----------------------------------------------------------------------------- class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice { - // A reference counted cairo surface - class BitmapPlatformDeviceData; - public: // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; // you should probably be using Create(). This may become private later if @@ -67,7 +64,7 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice { // the Windows and Mac versions of this class do. // // This object takes ownership of @data. - BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); + BitmapPlatformDevice(const SkBitmap& other, cairo_surface_t* surface); virtual ~BitmapPlatformDevice(); // Constructs a device with size |width| * |height| with contents initialized @@ -104,7 +101,29 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice { static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, cairo_surface_t* surface); - scoped_refptr<BitmapPlatformDeviceData> data_; + // Sets the transform and clip operations. This will not update the Cairo + // context, but will mark the config as dirty. The next call of LoadConfig + // will pick up these changes. + void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); + + // Loads the current transform and clip into the context. + void LoadConfig(); + + // Graphics context used to draw into the surface. + cairo_t* cairo_; + + // True when there is a transform or clip that has not been set to the + // context. The context is retrieved for every text operation, and the + // transform and clip do not change as much. We can save time by not loading + // the clip and transform for every one. + bool config_dirty_; + + // Translation assigned to the context: we need to keep track of this + // separately so it can be updated even if the context isn't created yet. + SkMatrix transform_; + + // The current clipping + SkRegion clip_region_; DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); }; |