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

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
« no previous file with comments | « skia/ext/bitmap_platform_device_android.cc ('k') | skia/ext/bitmap_platform_device_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/bitmap_platform_device_linux.cc
===================================================================
--- skia/ext/bitmap_platform_device_linux.cc (revision 161107)
+++ 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,28 @@
data_->SetMatrixClip(transform, region);
}
+// Port of PlatformBitmap to linux
+
+PlatformBitmap::~PlatformBitmap() {
+ cairo_destroy(surface_);
+}
+
+bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
+ cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ width, height);
+ if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy(surf);
+ return false;
+ }
+
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height,
+ cairo_image_surface_get_stride(surf));
+ bitmap_.setPixels(cairo_image_surface_get_data(surf));
+ bitmap_.setIsOpaque(is_opaque);
+
+ surface_ = cairo_create(surf);
+ cairo_surface_destroy(surf);
+ return true;
+}
+
} // namespace skia
« no previous file with comments | « skia/ext/bitmap_platform_device_android.cc ('k') | skia/ext/bitmap_platform_device_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698