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

Unified Diff: skia/ext/bitmap_platform_device_linux.cc

Issue 18678: Linux Skia: add an option to build a canvas from a provided memory buffer (Closed)
Patch Set: ... Created 11 years, 11 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_linux.h ('k') | skia/ext/platform_canvas_linux.h » ('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
diff --git a/skia/ext/bitmap_platform_device_linux.cc b/skia/ext/bitmap_platform_device_linux.cc
index 6f7277e3afe162ad731c2e4e4847be7e1e2a0135..f6a0e6d07b80e11cb2b8570400a17c2fba5cc84a 100644
--- a/skia/ext/bitmap_platform_device_linux.cc
+++ b/skia/ext/bitmap_platform_device_linux.cc
@@ -41,11 +41,7 @@ class BitmapPlatformDeviceLinux::BitmapPlatformDeviceLinuxData
// required so that we can call the base class' constructor with the pixel
// data.
BitmapPlatformDeviceLinux* BitmapPlatformDeviceLinux::Create(
- int width, int height, bool is_opaque) {
- cairo_surface_t* surface =
- cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
- width, height);
-
+ int width, int height, bool is_opaque, cairo_surface_t* surface) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height,
cairo_image_surface_get_stride(surface));
@@ -63,6 +59,24 @@ BitmapPlatformDeviceLinux* BitmapPlatformDeviceLinux::Create(
(bitmap, new BitmapPlatformDeviceLinuxData(surface));
}
+BitmapPlatformDeviceLinux* BitmapPlatformDeviceLinux::Create(
+ int width, int height, bool is_opaque) {
+ cairo_surface_t* surface =
+ cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ width, height);
+
+ return Create(width, height, is_opaque, surface);
+}
+
+BitmapPlatformDeviceLinux* BitmapPlatformDeviceLinux::Create(
+ int width, int height, bool is_opaque, uint8_t* data) {
+ cairo_surface_t* surface = cairo_image_surface_create_for_data(
+ data, CAIRO_FORMAT_ARGB32, width, height,
+ cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width));
+
+ return Create(width, height, is_opaque, surface);
+}
+
// The device will own the bitmap, which corresponds to also owning the pixel
// data. Therefore, we do not transfer ownership to the SkDevice's bitmap.
BitmapPlatformDeviceLinux::BitmapPlatformDeviceLinux(
« no previous file with comments | « skia/ext/bitmap_platform_device_linux.h ('k') | skia/ext/platform_canvas_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698