Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: skia/ext/bitmap_platform_device_linux.cc

Issue 11031055: Introduce PlatformBitmap, which is a minimal helper class that wraps an SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: skia/ext/bitmap_platform_device_linux.cc
===================================================================
--- skia/ext/bitmap_platform_device_linux.cc (revision 160846)
+++ skia/ext/bitmap_platform_device_linux.cc (working copy)
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "skia/ext/bitmap_platform_device_linux.h"
-
#include "skia/ext/bitmap_platform_device_data.h"
+#include "skia/ext/platform_canvas.h"
#if defined(OS_OPENBSD)
#include <cairo.h>
@@ -176,4 +176,36 @@
data_->SetMatrixClip(transform, region);
}
+// Port of PlatformBitmap to linux
+
+PlatformBitmap::~PlatformBitmap() {
+ cairo_destroy(surface_);
+}
+
+bool PlatformBitmap::Allocate(int width, int height, bool isOpaque) {
+ cairo_surface_t* cairo_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ width, height);
brettw 2012/10/09 20:40:12 Check indenting.
reed1 2012/10/09 21:06:43 Done.
+ if (cairo_surface_status(cairo_surf) != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy(cairo_surf);
+ return false;
+ }
+
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height,
+ cairo_image_surface_get_stride(cairo_surf));
+ bitmap_.setPixels(cairo_image_surface_get_data(cairo_surf));
+ bitmap_.setIsOpaque(isOpaque);
+
+ surface_ = cairo_create(cairo_surf);
+ cairo_surface_destroy(cairo_surf);
+ return true;
+}
+
+PlatformSurface PlatformBitmap::LockSurface() {
+ return surface_;
+}
+
+void PlatformBitmap::UnlockSurface() {
+ // nothing to do for our surface. It will be released in our destructor
brettw 2012/10/09 20:40:12 Check indenting.
reed1 2012/10/09 21:06:43 Done.
+}
+
} // namespace skia

Powered by Google App Engine
This is Rietveld 408576698