Index: base/gfx/bitmap_platform_device_linux.h |
diff --git a/base/gfx/bitmap_platform_device_linux.h b/base/gfx/bitmap_platform_device_linux.h |
index 99ca534d09acf145d8f02b630f288fcbdd4642bc..9b0328b90bd65734af3f66757b4a5246ea9122e6 100644 |
--- a/base/gfx/bitmap_platform_device_linux.h |
+++ b/base/gfx/bitmap_platform_device_linux.h |
@@ -8,21 +8,52 @@ |
#include "base/gfx/platform_device_linux.h" |
#include "base/ref_counted.h" |
-#include <gdk-pixbuf/gdk-pixbuf.h> |
+struct _cairo_surface; |
Evan Martin
2008/11/05 23:52:23
this isn't necessary when you have the following l
|
+typedef struct _cairo_surface cairo_surface_t; |
+ |
+// ----------------------------------------------------------------------------- |
+// Image byte ordering on Linux: |
+// |
+// Pixels are packed into 32-bit words these days. Even for 24-bit images, |
+// often 8-bits will be left unused for alignment reasons. Thus, when you see |
+// ARGB as the byte order you have to wonder if that's in memory order or |
+// little-endian order. Here I'll write A.R.G.B to specifiy the memory order. |
+// |
+// GdkPixbuf's provide a nice backing store and defaults to R.G.B.A order. |
+// They'll do the needed byte swapping to match the X server when drawn. |
+// |
+// Skia can be controled in skia/include/corecg/SkUserConfig.h (see bits about |
+// SK_R32_SHIFT). For Linux we define it to be ARGB in registers. For little |
+// endian machines that means B.G.R.A in memory. |
+// |
+// The image loaders are controlled in |
+// webkit/port/platform/image-decoders/ImageDecoder.h (see setRGBA). These are |
+// also configured for ARGB in registers. |
+// |
+// Cairo's only 32-bit mode is ARGB in registers. |
+// |
+// X servers commonly have a 32-bit visual with xRGB in registers (since they |
+// typically don't do alpha blending of drawables at the user level. Composite |
+// extensions aside.) |
+// |
+// We don't use GdkPixbuf because its byte order differs from the rest. Most |
+// importantly, it differs from Cairo which, being a system library, is |
+// something that we can't easily change. |
+// ----------------------------------------------------------------------------- |
namespace gfx { |
// ----------------------------------------------------------------------------- |
-// This is the Linux bitmap backing for Skia. It's a GdkPixbuf of the correct |
-// size and we implement a SkPixelRef in order that Skia can write directly to |
-// the pixel memory backing the Pixbuf. |
+// This is the Linux bitmap backing for Skia. We create a Cairo image surface |
+// to store the backing buffer. This buffer is BGRA in memory (on little-endian |
+// machines). |
// |
-// We then provide an accessor for getting the pixbuf object and that can be |
-// drawn to a GDK drawing area to display the rendering result. |
+// For now we are also using Cairo to paint to the Drawables so we provide an |
+// accessor for getting the surface. |
// |
// This is all quite ok for test_shell. In the future we will want to use |
// shared memory between the renderer and the main process at least. In this |
-// case we'll probably create the pixbuf from a precreated region of memory. |
+// case we'll probably create the buffer from a precreated region of memory. |
// ----------------------------------------------------------------------------- |
class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { |
public: |
@@ -30,11 +61,13 @@ class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { |
static BitmapPlatformDeviceLinux* Create(int width, int height, |
bool is_opaque); |
- /// Create a BitmapPlatformDeviceLinux from an already constructed bitmap; |
- /// you should probably be using Create(). This may become private later if |
- /// we ever have to share state between some native drawing UI and Skia, like |
- /// the Windows and Mac versions of this class do. |
- BitmapPlatformDeviceLinux(const SkBitmap& other, GdkPixbuf* pixbuf); |
+ // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; |
+ // you should probably be using Create(). This may become private later if |
+ // we ever have to share state between some native drawing UI and Skia, like |
+ // the Windows and Mac versions of this class do. |
+ // |
+ // This object takes ownership of @surface. |
+ BitmapPlatformDeviceLinux(const SkBitmap& other, cairo_surface_t* surface); |
virtual ~BitmapPlatformDeviceLinux(); |
// A stub copy constructor. Needs to be properly implemented. |
@@ -43,10 +76,10 @@ class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { |
// Bitmaps aren't vector graphics. |
virtual bool IsVectorial() { return false; } |
- GdkPixbuf* pixbuf() const { return pixbuf_; } |
+ cairo_surface_t* surface() const { return surface_; } |
private: |
- GdkPixbuf* pixbuf_; |
+ cairo_surface_t* surface_; |
}; |
} // namespace gfx |