summaryrefslogtreecommitdiffstats
path: root/skia/ext/bitmap_platform_device_linux.cc
diff options
context:
space:
mode:
Diffstat (limited to 'skia/ext/bitmap_platform_device_linux.cc')
-rw-r--r--skia/ext/bitmap_platform_device_linux.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/skia/ext/bitmap_platform_device_linux.cc b/skia/ext/bitmap_platform_device_linux.cc
index 562e7fc..63b44a6 100644
--- a/skia/ext/bitmap_platform_device_linux.cc
+++ b/skia/ext/bitmap_platform_device_linux.cc
@@ -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 @@ void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
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