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