OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 public: | 64 public: |
65 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; | 65 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; |
66 // you should probably be using Create(). This may become private later if | 66 // you should probably be using Create(). This may become private later if |
67 // we ever have to share state between some native drawing UI and Skia, like | 67 // we ever have to share state between some native drawing UI and Skia, like |
68 // the Windows and Mac versions of this class do. | 68 // the Windows and Mac versions of this class do. |
69 // | 69 // |
70 // This object takes ownership of @data. | 70 // This object takes ownership of @data. |
71 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); | 71 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); |
72 virtual ~BitmapPlatformDevice(); | 72 virtual ~BitmapPlatformDevice(); |
73 | 73 |
| 74 // Constructs a device with size |width| * |height| with contents initialized |
| 75 // to zero. |is_opaque| should be set if the caller knows the bitmap will be |
| 76 // completely opaque and allows some optimizations. |
74 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); | 77 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); |
75 | 78 |
76 // This doesn't take ownership of |data| | 79 // Performs the same construction as Create. |
| 80 // Other ports require a separate construction routine because Create does not |
| 81 // initialize the bitmap to 0. |
| 82 static BitmapPlatformDevice* CreateAndClear(int width, int height, |
| 83 bool is_opaque); |
| 84 |
| 85 // This doesn't take ownership of |data|. If |data| is NULL, the contents |
| 86 // of the device are initialized to 0. |
77 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 87 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
78 uint8_t* data); | 88 uint8_t* data); |
79 | 89 |
80 // Overridden from SkDevice: | 90 // Overridden from SkDevice: |
81 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 91 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
82 const SkClipStack&) OVERRIDE; | 92 const SkClipStack&) OVERRIDE; |
83 | 93 |
84 // Overridden from PlatformDevice: | 94 // Overridden from PlatformDevice: |
85 virtual cairo_t* BeginPlatformPaint() OVERRIDE; | 95 virtual cairo_t* BeginPlatformPaint() OVERRIDE; |
86 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, | 96 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, |
87 const PlatformRect* src_rect) OVERRIDE; | 97 const PlatformRect* src_rect) OVERRIDE; |
88 | 98 |
89 protected: | 99 protected: |
90 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 100 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
91 int height, bool isOpaque, | 101 int height, bool isOpaque, |
92 Usage usage) OVERRIDE; | 102 Usage usage) OVERRIDE; |
93 | 103 |
94 private: | 104 private: |
95 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 105 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
96 cairo_surface_t* surface); | 106 cairo_surface_t* surface); |
97 | 107 |
98 scoped_refptr<BitmapPlatformDeviceData> data_; | 108 scoped_refptr<BitmapPlatformDeviceData> data_; |
99 | 109 |
100 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 110 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
101 }; | 111 }; |
102 | 112 |
103 } // namespace skia | 113 } // namespace skia |
104 | 114 |
105 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 115 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
OLD | NEW |