summaryrefslogtreecommitdiffstats
path: root/skia/ext/platform_canvas.h
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 19:57:15 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 19:57:15 +0000
commit3b798343ad6244041f094ab1c7929cddef451945 (patch)
treef95ab6f60499c493016870931161e879a86e2e6f /skia/ext/platform_canvas.h
parentb27ccd4d945890566a5897d7dc903ebd67c76948 (diff)
downloadchromium_src-3b798343ad6244041f094ab1c7929cddef451945.zip
chromium_src-3b798343ad6244041f094ab1c7929cddef451945.tar.gz
chromium_src-3b798343ad6244041f094ab1c7929cddef451945.tar.bz2
Introduce PlatformBitmap, which is a minimal helper class that wraps an SkBitmap
and a PlatformSurface. This is used to replace the PlatformCanvas that was being passed to BackingStore to return pixels. The problem to solve is that PlatformCanvas is an extension of SkCanvas, and SkCanvas is losing the ability to have its backend specified after its constructor (for performance reasons). The BackingStore interface only needs to return a copy of its pixels, and offer a platform-specific way to draw into it (i.e. BitBlt). The PlatformSurface is sufficient for this, so the larger infrastructure of PlatformCanvas/PlatformDevice is not required. Review URL: https://codereview.chromium.org/11031055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/platform_canvas.h')
-rw-r--r--skia/ext/platform_canvas.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h
index e030ad7..4d2b0c0 100644
--- a/skia/ext/platform_canvas.h
+++ b/skia/ext/platform_canvas.h
@@ -7,6 +7,7 @@
// The platform-specific device will include the necessary platform headers
// to get the surface type.
+#include "base/basictypes.h"
#include "skia/ext/platform_device.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -151,6 +152,28 @@ class SK_API ScopedPlatformPaint {
ScopedPlatformPaint& operator=(const ScopedPlatformPaint&);
};
+class SK_API PlatformBitmap {
+ public:
+ PlatformBitmap();
+ ~PlatformBitmap();
+
+ // Returns true if the bitmap was able to allocate its surface.
+ bool Allocate(int width, int height, bool is_opaque);
+
+ // Returns the platform surface, or 0 if Allocate() did not return true.
+ PlatformSurface GetSurface() { return surface_; }
+
+ // Return the skia bitmap, which will be empty if Allocate() did not
+ // return true.
+ const SkBitmap& GetBitmap() { return bitmap_; }
+
+ private:
+ SkBitmap bitmap_;
+ PlatformSurface surface_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformBitmap);
+};
+
} // namespace skia
#endif // SKIA_EXT_PLATFORM_CANVAS_H_