| OLD | NEW |
| 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 // TODO(brettw) this file should be removed and the includes changed to this |
| 9 #include "base/ref_counted.h" | 9 // new location. |
| 10 | 10 #include "webkit/port/platform/graphics/skia/public/BitmapPlatformDeviceLinux.h" |
| 11 typedef struct _cairo_surface cairo_surface_t; | |
| 12 | |
| 13 // ----------------------------------------------------------------------------- | |
| 14 // Image byte ordering on Linux: | |
| 15 // | |
| 16 // Pixels are packed into 32-bit words these days. Even for 24-bit images, | |
| 17 // often 8-bits will be left unused for alignment reasons. Thus, when you see | |
| 18 // ARGB as the byte order you have to wonder if that's in memory order or | |
| 19 // little-endian order. Here I'll write A.R.G.B to specifiy the memory order. | |
| 20 // | |
| 21 // GdkPixbuf's provide a nice backing store and defaults to R.G.B.A order. | |
| 22 // They'll do the needed byte swapping to match the X server when drawn. | |
| 23 // | |
| 24 // Skia can be controled in skia/include/corecg/SkUserConfig.h (see bits about | |
| 25 // SK_R32_SHIFT). For Linux we define it to be ARGB in registers. For little | |
| 26 // endian machines that means B.G.R.A in memory. | |
| 27 // | |
| 28 // The image loaders are controlled in | |
| 29 // webkit/port/platform/image-decoders/ImageDecoder.h (see setRGBA). These are | |
| 30 // also configured for ARGB in registers. | |
| 31 // | |
| 32 // Cairo's only 32-bit mode is ARGB in registers. | |
| 33 // | |
| 34 // X servers commonly have a 32-bit visual with xRGB in registers (since they | |
| 35 // typically don't do alpha blending of drawables at the user level. Composite | |
| 36 // extensions aside.) | |
| 37 // | |
| 38 // We don't use GdkPixbuf because its byte order differs from the rest. Most | |
| 39 // importantly, it differs from Cairo which, being a system library, is | |
| 40 // something that we can't easily change. | |
| 41 // ----------------------------------------------------------------------------- | |
| 42 | |
| 43 namespace gfx { | |
| 44 | |
| 45 // ----------------------------------------------------------------------------- | |
| 46 // This is the Linux bitmap backing for Skia. We create a Cairo image surface | |
| 47 // to store the backing buffer. This buffer is BGRA in memory (on little-endian | |
| 48 // machines). | |
| 49 // | |
| 50 // For now we are also using Cairo to paint to the Drawables so we provide an | |
| 51 // accessor for getting the surface. | |
| 52 // | |
| 53 // This is all quite ok for test_shell. In the future we will want to use | |
| 54 // shared memory between the renderer and the main process at least. In this | |
| 55 // case we'll probably create the buffer from a precreated region of memory. | |
| 56 // ----------------------------------------------------------------------------- | |
| 57 class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { | |
| 58 // A reference counted cairo surface | |
| 59 class BitmapPlatformDeviceLinuxData; | |
| 60 | |
| 61 public: | |
| 62 /// Static constructor. I don't understand this, it's just a copy of the mac | |
| 63 static BitmapPlatformDeviceLinux* Create(int width, int height, | |
| 64 bool is_opaque); | |
| 65 | |
| 66 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; | |
| 67 // you should probably be using Create(). This may become private later if | |
| 68 // we ever have to share state between some native drawing UI and Skia, like | |
| 69 // the Windows and Mac versions of this class do. | |
| 70 // | |
| 71 // This object takes ownership of @data. | |
| 72 BitmapPlatformDeviceLinux(const SkBitmap& other, | |
| 73 BitmapPlatformDeviceLinuxData* data); | |
| 74 virtual ~BitmapPlatformDeviceLinux(); | |
| 75 BitmapPlatformDeviceLinux& operator=(const BitmapPlatformDeviceLinux& other); | |
| 76 | |
| 77 // A stub copy constructor. Needs to be properly implemented. | |
| 78 BitmapPlatformDeviceLinux(const BitmapPlatformDeviceLinux& other); | |
| 79 | |
| 80 // Bitmaps aren't vector graphics. | |
| 81 virtual bool IsVectorial() { return false; } | |
| 82 | |
| 83 cairo_surface_t* surface() const; | |
| 84 | |
| 85 private: | |
| 86 scoped_refptr<BitmapPlatformDeviceLinuxData> data_; | |
| 87 }; | |
| 88 | |
| 89 } // namespace gfx | |
| 90 | 11 |
| 91 #endif // BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 12 #endif // BASE_GFX_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
| OLD | NEW |