| 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 // 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 |
| 15 // 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 |
| 16 // write to. BitmapPlatformDevice creates a bitmap using | 16 // write to. BitmapPlatformDevice creates a bitmap using |
| 17 // 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 |
| 18 // 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 |
| 19 // device contains so that it can be shared. | 19 // device contains so that it can be shared. |
| 20 // | 20 // |
| 21 // 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 |
| 22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses | 22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses |
| 23 // 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 |
| 24 // another bitmap to this device's bitmap and everything will work properly. | 24 // another bitmap to this device's bitmap and everything will work properly. |
| 25 // For us, that other bitmap will become invalid as soon as the device becomes | 25 // For us, that other bitmap will become invalid as soon as the device becomes |
| 26 // invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE | 26 // invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE |
| 27 // DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead. | 27 // DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead. |
| 28 class BitmapPlatformDevice : public PlatformDevice { | 28 class BitmapPlatformDevice : public PlatformDevice, public SkDevice { |
| 29 public: | 29 public: |
| 30 // |context| may be NULL. | 30 // |context| may be NULL. |
| 31 static BitmapPlatformDevice* Create(CGContextRef context, | 31 static BitmapPlatformDevice* Create(CGContextRef context, |
| 32 int width, int height, | 32 int width, int height, |
| 33 bool is_opaque); | 33 bool is_opaque); |
| 34 | 34 |
| 35 // Creates a context for |data| and calls Create. | 35 // Creates a context for |data| and calls Create. |
| 36 static BitmapPlatformDevice* CreateWithData(uint8_t* data, | 36 static BitmapPlatformDevice* CreateWithData(uint8_t* data, |
| 37 int width, int height, | 37 int width, int height, |
| 38 bool is_opaque); | 38 bool is_opaque); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // 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 |
| 71 // to this object. | 71 // to this object. |
| 72 BitmapPlatformDeviceData* data_; | 72 BitmapPlatformDeviceData* data_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 74 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace skia | 77 } // namespace skia |
| 78 | 78 |
| 79 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 79 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
| OLD | NEW |