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

Unified Diff: skia/ext/platform_canvas_linux.h

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.cc ('k') | skia/ext/platform_canvas_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/platform_canvas_linux.h
diff --git a/skia/ext/platform_canvas_linux.h b/skia/ext/platform_canvas_linux.h
index 1a5afe7925666a734776b67bcbcfa903cda3c55f..5782284073ceb2cf501cc7250772f78fb99e7eac 100644
--- a/skia/ext/platform_canvas_linux.h
+++ b/skia/ext/platform_canvas_linux.h
@@ -5,6 +5,8 @@
#ifndef SKIA_EXT_PLATFORM_CANVAS_LINUX_H_
#define SKIA_EXT_PLATFORM_CANVAS_LINUX_H_
+#include <unistd.h>
+
#include "skia/ext/platform_device_linux.h"
namespace skia {
@@ -21,6 +23,9 @@ class PlatformCanvasLinux : public SkCanvas {
// If you use the version with no arguments, you MUST call initialize()
PlatformCanvasLinux();
PlatformCanvasLinux(int width, int height, bool is_opaque);
+ // Construct a canvas from the given memory region. The memory is not cleared
+ // first. @data must be, at least, @height * StrideForWidth(@width) bytes.
+ PlatformCanvasLinux(int width, int height, bool is_opaque, uint8_t* data);
virtual ~PlatformCanvasLinux();
// For two-part init, call if you use the no-argument constructor above
@@ -31,6 +36,11 @@ class PlatformCanvasLinux : public SkCanvas {
// a Linux version is added for compatibility.
PlatformDeviceLinux& getTopPlatformDevice() const;
+ // Return the stride (length of a line in bytes) for the given width. Because
+ // we use 32-bits per pixel, this will be roughly 4*width. However, for
+ // alignment reasons we may wish to increase that.
+ static size_t StrideForWidth(unsigned width);
+
protected:
// Creates a device store for use by the canvas. We override this so that
// the device is always our own so we know that we can use GDI operations
« no previous file with comments | « skia/ext/bitmap_platform_device_linux.cc ('k') | skia/ext/platform_canvas_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698