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

Side by Side Diff: base/gfx/bitmap_platform_device_linux.h

Issue 8227: Switch from using GdkPixbuf to cairo for painting on Drawables. (Closed)
Patch Set: Address comments Created 12 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/gfx/bitmap_platform_device_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_ 5 #ifndef BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_
6 #define BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_ 6 #define BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_
7 7
8 #include "base/gfx/platform_device_linux.h" 8 #include "base/gfx/platform_device_linux.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 10
11 #include <gdk-pixbuf/gdk-pixbuf.h> 11 struct _cairo_surface;
Evan Martin 2008/11/05 23:52:23 this isn't necessary when you have the following l
12 typedef struct _cairo_surface cairo_surface_t;
13
14 // -----------------------------------------------------------------------------
15 // Image byte ordering on Linux:
16 //
17 // Pixels are packed into 32-bit words these days. Even for 24-bit images,
18 // often 8-bits will be left unused for alignment reasons. Thus, when you see
19 // ARGB as the byte order you have to wonder if that's in memory order or
20 // little-endian order. Here I'll write A.R.G.B to specifiy the memory order.
21 //
22 // GdkPixbuf's provide a nice backing store and defaults to R.G.B.A order.
23 // They'll do the needed byte swapping to match the X server when drawn.
24 //
25 // Skia can be controled in skia/include/corecg/SkUserConfig.h (see bits about
26 // SK_R32_SHIFT). For Linux we define it to be ARGB in registers. For little
27 // endian machines that means B.G.R.A in memory.
28 //
29 // The image loaders are controlled in
30 // webkit/port/platform/image-decoders/ImageDecoder.h (see setRGBA). These are
31 // also configured for ARGB in registers.
32 //
33 // Cairo's only 32-bit mode is ARGB in registers.
34 //
35 // X servers commonly have a 32-bit visual with xRGB in registers (since they
36 // typically don't do alpha blending of drawables at the user level. Composite
37 // extensions aside.)
38 //
39 // We don't use GdkPixbuf because its byte order differs from the rest. Most
40 // importantly, it differs from Cairo which, being a system library, is
41 // something that we can't easily change.
42 // -----------------------------------------------------------------------------
12 43
13 namespace gfx { 44 namespace gfx {
14 45
15 // ----------------------------------------------------------------------------- 46 // -----------------------------------------------------------------------------
16 // This is the Linux bitmap backing for Skia. It's a GdkPixbuf of the correct 47 // This is the Linux bitmap backing for Skia. We create a Cairo image surface
17 // size and we implement a SkPixelRef in order that Skia can write directly to 48 // to store the backing buffer. This buffer is BGRA in memory (on little-endian
18 // the pixel memory backing the Pixbuf. 49 // machines).
19 // 50 //
20 // We then provide an accessor for getting the pixbuf object and that can be 51 // For now we are also using Cairo to paint to the Drawables so we provide an
21 // drawn to a GDK drawing area to display the rendering result. 52 // accessor for getting the surface.
22 // 53 //
23 // This is all quite ok for test_shell. In the future we will want to use 54 // This is all quite ok for test_shell. In the future we will want to use
24 // shared memory between the renderer and the main process at least. In this 55 // shared memory between the renderer and the main process at least. In this
25 // case we'll probably create the pixbuf from a precreated region of memory. 56 // case we'll probably create the buffer from a precreated region of memory.
26 // ----------------------------------------------------------------------------- 57 // -----------------------------------------------------------------------------
27 class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { 58 class BitmapPlatformDeviceLinux : public PlatformDeviceLinux {
28 public: 59 public:
29 /// Static constructor. I don't understand this, it's just a copy of the mac 60 /// Static constructor. I don't understand this, it's just a copy of the mac
30 static BitmapPlatformDeviceLinux* Create(int width, int height, 61 static BitmapPlatformDeviceLinux* Create(int width, int height,
31 bool is_opaque); 62 bool is_opaque);
32 63
33 /// Create a BitmapPlatformDeviceLinux from an already constructed bitmap; 64 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap;
34 /// you should probably be using Create(). This may become private later if 65 // you should probably be using Create(). This may become private later if
35 /// we ever have to share state between some native drawing UI and Skia, like 66 // we ever have to share state between some native drawing UI and Skia, like
36 /// the Windows and Mac versions of this class do. 67 // the Windows and Mac versions of this class do.
37 BitmapPlatformDeviceLinux(const SkBitmap& other, GdkPixbuf* pixbuf); 68 //
69 // This object takes ownership of @surface.
70 BitmapPlatformDeviceLinux(const SkBitmap& other, cairo_surface_t* surface);
38 virtual ~BitmapPlatformDeviceLinux(); 71 virtual ~BitmapPlatformDeviceLinux();
39 72
40 // A stub copy constructor. Needs to be properly implemented. 73 // A stub copy constructor. Needs to be properly implemented.
41 BitmapPlatformDeviceLinux(const BitmapPlatformDeviceLinux& other); 74 BitmapPlatformDeviceLinux(const BitmapPlatformDeviceLinux& other);
42 75
43 // Bitmaps aren't vector graphics. 76 // Bitmaps aren't vector graphics.
44 virtual bool IsVectorial() { return false; } 77 virtual bool IsVectorial() { return false; }
45 78
46 GdkPixbuf* pixbuf() const { return pixbuf_; } 79 cairo_surface_t* surface() const { return surface_; }
47 80
48 private: 81 private:
49 GdkPixbuf* pixbuf_; 82 cairo_surface_t* surface_;
50 }; 83 };
51 84
52 } // namespace gfx 85 } // namespace gfx
53 86
54 #endif // BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_ 87 #endif // BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | base/gfx/bitmap_platform_device_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698