summaryrefslogtreecommitdiffstats
path: root/skia/ext/bitmap_platform_device_linux.h
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-22 00:10:00 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-22 00:10:00 +0000
commit8c2fcd19acaa0b3aeeae0aacd0f698d9d0e4b0a4 (patch)
tree9ae4cf3df2df8b9816abbeeefcde36b6dd33a040 /skia/ext/bitmap_platform_device_linux.h
parentfbbb58d4c5cc57c72b84ee4337b155e2a64224e1 (diff)
downloadchromium_src-8c2fcd19acaa0b3aeeae0aacd0f698d9d0e4b0a4.zip
chromium_src-8c2fcd19acaa0b3aeeae0aacd0f698d9d0e4b0a4.tar.gz
chromium_src-8c2fcd19acaa0b3aeeae0aacd0f698d9d0e4b0a4.tar.bz2
Move port/.../skia/public to skia/ext for Linux. Windows & Mac already moved there. This leaves forwarding headers in base/gfx, which I'll clean up in a future pass.
Review URL: http://codereview.chromium.org/11808 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/bitmap_platform_device_linux.h')
-rw-r--r--skia/ext/bitmap_platform_device_linux.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/skia/ext/bitmap_platform_device_linux.h b/skia/ext/bitmap_platform_device_linux.h
new file mode 100644
index 0000000..14e4c0c
--- /dev/null
+++ b/skia/ext/bitmap_platform_device_linux.h
@@ -0,0 +1,91 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
+#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
+
+#include "base/ref_counted.h"
+#include "skia/ext/platform_device_linux.h"
+
+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. We create a Cairo image surface
+// to store the backing buffer. This buffer is BGRA in memory (on little-endian
+// machines).
+//
+// 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 buffer from a precreated region of memory.
+// -----------------------------------------------------------------------------
+class BitmapPlatformDeviceLinux : public PlatformDeviceLinux {
+ // A reference counted cairo surface
+ class BitmapPlatformDeviceLinuxData;
+
+ public:
+ /// Static constructor. I don't understand this, it's just a copy of the mac
+ 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.
+ //
+ // This object takes ownership of @data.
+ BitmapPlatformDeviceLinux(const SkBitmap& other,
+ BitmapPlatformDeviceLinuxData* data);
+ virtual ~BitmapPlatformDeviceLinux();
+ BitmapPlatformDeviceLinux& operator=(const BitmapPlatformDeviceLinux& other);
+
+ // A stub copy constructor. Needs to be properly implemented.
+ BitmapPlatformDeviceLinux(const BitmapPlatformDeviceLinux& other);
+
+ // Bitmaps aren't vector graphics.
+ virtual bool IsVectorial() { return false; }
+
+ cairo_surface_t* surface() const;
+
+ private:
+ scoped_refptr<BitmapPlatformDeviceLinuxData> data_;
+};
+
+} // namespace gfx
+
+#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_