OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SKIA_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ |
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "skia/ext/platform_device.h" | 13 #include "skia/ext/platform_device.h" |
14 | 14 |
15 namespace skia { | 15 namespace skia { |
16 | 16 |
17 // ----------------------------------------------------------------------------- | 17 // ----------------------------------------------------------------------------- |
18 // For now we just use SkBitmap for SkBitmapDevice | 18 // For now we just use SkBitmap for SkBitmapDevice |
19 // | 19 // |
20 // This is all quite ok for test_shell. In the future we will want to use | 20 // This is all quite ok for test_shell. In the future we will want to use |
21 // shared memory between the renderer and the main process at least. In this | 21 // shared memory between the renderer and the main process at least. In this |
22 // case we'll probably create the buffer from a precreated region of memory. | 22 // case we'll probably create the buffer from a precreated region of memory. |
23 // ----------------------------------------------------------------------------- | 23 // ----------------------------------------------------------------------------- |
24 class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice { | 24 class BitmapPlatformDevice final : public SkBitmapDevice, |
| 25 public PlatformDevice { |
25 public: | 26 public: |
26 // Construct a BitmapPlatformDevice. |is_opaque| should be set if the caller | 27 // Construct a BitmapPlatformDevice. |is_opaque| should be set if the caller |
27 // knows the bitmap will be completely opaque and allows some optimizations. | 28 // knows the bitmap will be completely opaque and allows some optimizations |
28 // The bitmap is not initialized. | 29 // (the bitmap is not initialized to 0 when is_opaque == true). |
29 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); | 30 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); |
30 | 31 |
31 // This doesn't take ownership of |data|. If |data| is null, the bitmap | 32 // This doesn't take ownership of |data|. If |data| is null and |is_opaque| |
32 // is not initialized to 0. | 33 // is false, the bitmap is initialized to 0. |
| 34 // |
| 35 // Note: historicaly, BitmapPlatformDevice impls have had diverging |
| 36 // initialization behavior for null |data| (Cairo used to initialize, while |
| 37 // the others did not). For now we stick to the more conservative Cairo |
| 38 // behavior. |
33 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 39 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
34 uint8_t* data); | 40 uint8_t* data); |
35 | 41 |
36 // Create a BitmapPlatformDevice from an already constructed bitmap; | 42 // Create a BitmapPlatformDevice from an already constructed bitmap; |
37 // you should probably be using Create(). This may become private later if | 43 // you should probably be using Create(). This may become private later if |
38 // we ever have to share state between some native drawing UI and Skia, like | 44 // we ever have to share state between some native drawing UI and Skia, like |
39 // the Windows and Mac versions of this class do. | 45 // the Windows and Mac versions of this class do. |
40 explicit BitmapPlatformDevice(const SkBitmap& other); | 46 explicit BitmapPlatformDevice(const SkBitmap& other); |
41 ~BitmapPlatformDevice() override; | 47 ~BitmapPlatformDevice() override; |
42 | 48 |
43 protected: | 49 protected: |
44 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 50 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
45 | 51 |
46 private: | 52 private: |
47 NativeDrawingContext BeginPlatformPaint(const SkMatrix& transform, | |
48 const SkIRect& clip_bounds) override; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 53 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
51 }; | 54 }; |
52 | 55 |
53 } // namespace skia | 56 } // namespace skia |
54 | 57 |
55 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ | 58 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ |
OLD | NEW |