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_MAC_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "skia/ext/platform_device_mac.h" | 10 #include "skia/ext/platform_device_mac.h" |
11 | 11 |
12 namespace skia { | 12 namespace skia { |
13 | 13 |
14 class BitmapPlatformDeviceFactory : public SkDeviceFactory { | |
15 public: | |
16 virtual SkDevice* newDevice(SkCanvas* ignored, SkBitmap::Config config, | |
17 int width, int height, | |
18 bool isOpaque, bool isForLayer); | |
19 }; | |
20 | |
21 | |
22 // A device is basically a wrapper around SkBitmap that provides a surface for | 14 // A device is basically a wrapper around SkBitmap that provides a surface for |
23 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also | 15 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also |
24 // write to. BitmapPlatformDevice creates a bitmap using | 16 // write to. BitmapPlatformDevice creates a bitmap using |
25 // CGCreateBitmapContext() in a format that Skia supports and can then use this | 17 // CGCreateBitmapContext() in a format that Skia supports and can then use this |
26 // to draw text into, etc. This pixel data is provided to the bitmap that the | 18 // to draw text into, etc. This pixel data is provided to the bitmap that the |
27 // device contains so that it can be shared. | 19 // device contains so that it can be shared. |
28 // | 20 // |
29 // The device owns the pixel data, when the device goes away, the pixel data | 21 // The device owns the pixel data, when the device goes away, the pixel data |
30 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses | 22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses |
31 // reference counting for the pixel data. In normal Skia, you could assign | 23 // reference counting for the pixel data. In normal Skia, you could assign |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 class BitmapPlatformDeviceData; | 56 class BitmapPlatformDeviceData; |
65 | 57 |
66 BitmapPlatformDevice(BitmapPlatformDeviceData* data, | 58 BitmapPlatformDevice(BitmapPlatformDeviceData* data, |
67 const SkBitmap& bitmap); | 59 const SkBitmap& bitmap); |
68 | 60 |
69 // Flushes the CoreGraphics context so that the pixel data can be accessed | 61 // Flushes the CoreGraphics context so that the pixel data can be accessed |
70 // directly by Skia. Overridden from SkDevice, this is called when Skia | 62 // directly by Skia. Overridden from SkDevice, this is called when Skia |
71 // starts accessing pixel data. | 63 // starts accessing pixel data. |
72 virtual void onAccessBitmap(SkBitmap*); | 64 virtual void onAccessBitmap(SkBitmap*); |
73 | 65 |
74 // Override SkDevice. | 66 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
75 virtual SkDeviceFactory* onNewDeviceFactory(); | 67 int height, bool isOpaque, |
| 68 Usage usage); |
76 | 69 |
77 // Data associated with this device, guaranteed non-null. We hold a reference | 70 // Data associated with this device, guaranteed non-null. We hold a reference |
78 // to this object. | 71 // to this object. |
79 BitmapPlatformDeviceData* data_; | 72 BitmapPlatformDeviceData* data_; |
80 | 73 |
81 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 74 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
82 }; | 75 }; |
83 | 76 |
84 } // namespace skia | 77 } // namespace skia |
85 | 78 |
86 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 79 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
OLD | NEW |