summaryrefslogtreecommitdiffstats
path: root/skia/ext/platform_canvas.h
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 16:16:02 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 16:16:02 +0000
commitf2d4c672b6d6b80e376cff979b1ec28864b73fb6 (patch)
tree679a4a8178438947f2775a6d1ba5540be99ce00c /skia/ext/platform_canvas.h
parent49578ea329dae7f711ca1cde1ecade01e19a4f1b (diff)
downloadchromium_src-f2d4c672b6d6b80e376cff979b1ec28864b73fb6.zip
chromium_src-f2d4c672b6d6b80e376cff979b1ec28864b73fb6.tar.gz
chromium_src-f2d4c672b6d6b80e376cff979b1ec28864b73fb6.tar.bz2
Revert 86625 - 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 TBR=twiz@chromium.org Review URL: http://codereview.chromium.org/6987019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/platform_canvas.h')
-rw-r--r--skia/ext/platform_canvas.h76
1 files changed, 29 insertions, 47 deletions
diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h
index 58049e6..24f613a 100644
--- a/skia/ext/platform_canvas.h
+++ b/skia/ext/platform_canvas.h
@@ -63,6 +63,30 @@ class SK_API PlatformCanvas : public SkCanvas {
// Shared --------------------------------------------------------------------
+ // These calls should surround calls to platform drawing routines, the
+ // surface returned here can be used with the native platform routines
+ //
+ // Call endPlatformPaint when you are done and want to use Skia operations
+ // after calling the platform-specific beginPlatformPaint; this will
+ // synchronize the bitmap to OS if necessary.
+ PlatformDevice::PlatformSurface beginPlatformPaint() const;
+ void endPlatformPaint() const;
+
+ // Returns the platform device pointer of the topmost rect with a non-empty
+ // clip. In practice, this is usually either the top layer or nothing, since
+ // we usually set the clip to new layers when we make them.
+ //
+ // If there is no layer that is not all clipped out, this will return a
+ // dummy device so callers do not have to check. If you are concerned about
+ // performance, check the clip before doing any painting.
+ //
+ // This is different than SkCanvas' getDevice, because that returns the
+ // bottommost device.
+ //
+ // Danger: the resulting device should not be saved. It will be invalidated
+ // by the next call to save() or restore().
+ PlatformDevice& getTopPlatformDevice() const;
+
// Return the stride (length of a line in bytes) for the given width. Because
// we use 32-bits per pixel, this will be roughly 4*width. However, for
// alignment reasons we may wish to increase that.
@@ -85,26 +109,11 @@ class SK_API PlatformCanvas : public SkCanvas {
// CoreGraphics.
virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap);
- // Disallow copy and assign
+ // Disallow copy and assign.
PlatformCanvas(const PlatformCanvas&);
PlatformCanvas& operator=(const PlatformCanvas&);
};
-// Returns the SkDevice pointer of the topmost rect with a non-empty
-// clip. In practice, this is usually either the top layer or nothing, since
-// we usually set the clip to new layers when we make them.
-//
-// If there is no layer that is not all clipped out, this will return a
-// dummy device so callers do not have to check. If you are concerned about
-// performance, check the clip before doing any painting.
-//
-// This is different than SkCanvas' getDevice, because that returns the
-// bottommost device.
-//
-// Danger: the resulting device should not be saved. It will be invalidated
-// by the next call to save() or restore().
-SkDevice* GetTopDevice(const SkCanvas& canvas);
-
// Creates a canvas with raster bitmap backing.
// Set is_opaque if you are going to erase the bitmap and not use
// transparency: this will enable some optimizations.
@@ -115,45 +124,18 @@ SK_API SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque);
// return NULL PlatformSurface.
SK_API bool SupportsPlatformPaint(const SkCanvas* canvas);
-// Draws into the a native platform surface, |context|. Forwards to
-// DrawToNativeContext on a PlatformDevice instance bound to the top device.
-// If no PlatformDevice instance is bound, is a no-operation.
-SK_API void DrawToNativeContext(SkCanvas* canvas, 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(SkCanvas* canvas, int x, int y, int width, int height);
-
// These calls should surround calls to platform drawing routines, the
// surface returned here can be used with the native platform routines.
//
// Call EndPlatformPaint when you are done and want to use skia operations
// after calling the platform-specific BeginPlatformPaint; this will
// synchronize the bitmap to OS if necessary.
-SK_API PlatformSurface BeginPlatformPaint(SkCanvas* canvas);
+//
+// Note: These functions will eventually replace
+// PlatformCanvas::beginPlatformPaint and PlatformCanvas::endPlatformPaint.
+SK_API PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas);
SK_API void EndPlatformPaint(SkCanvas* canvas);
-// Helper class for pairing calls to BeginPlatformPaint and EndPlatformPaint.
-// Upon construction invokes BeginPlatformPaint, and upon destruction invokes
-// EndPlatformPaint.
-class ScopedPlatformPaint {
- public:
- explicit ScopedPlatformPaint(SkCanvas* canvas) : canvas_(canvas) {
- platform_surface_ = BeginPlatformPaint(canvas);
- }
- ~ScopedPlatformPaint() { EndPlatformPaint(canvas_); }
-
- // Returns the PlatformSurface to use for native platform drawing calls.
- PlatformSurface GetPlatformSurface() { return platform_surface_; }
- private:
- SkCanvas* canvas_;
- PlatformSurface platform_surface_;
-
- // Disallow copy and assign
- ScopedPlatformPaint(const ScopedPlatformPaint&);
- ScopedPlatformPaint& operator=(const ScopedPlatformPaint&);
-};
-
} // namespace skia
#endif // SKIA_EXT_PLATFORM_CANVAS_H_