| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "skia/ext/platform_device.h" | 10 #include "skia/ext/platform_device.h" |
| 11 #include "skia/ext/refptr.h" |
| 11 | 12 |
| 12 namespace skia { | 13 namespace skia { |
| 13 | 14 |
| 14 // A device is basically a wrapper around SkBitmap that provides a surface for | 15 // 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 | 16 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also |
| 16 // write to. BitmapPlatformDevice creates a bitmap using | 17 // write to. BitmapPlatformDevice creates a bitmap using |
| 17 // CGCreateBitmapContext() in a format that Skia supports and can then use this | 18 // 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 | 19 // to draw text into, etc. This pixel data is provided to the bitmap that the |
| 19 // device contains so that it can be shared. | 20 // device contains so that it can be shared. |
| 20 // | 21 // |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // SkDevice overrides | 58 // SkDevice overrides |
| 58 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 59 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
| 59 const SkClipStack&) OVERRIDE; | 60 const SkClipStack&) OVERRIDE; |
| 60 | 61 |
| 61 protected: | 62 protected: |
| 62 // Reference counted data that can be shared between multiple devices. This | 63 // Reference counted data that can be shared between multiple devices. This |
| 63 // allows copy constructors and operator= for devices to work properly. The | 64 // allows copy constructors and operator= for devices to work properly. The |
| 64 // bitmaps used by the base device class are already refcounted and copyable. | 65 // bitmaps used by the base device class are already refcounted and copyable. |
| 65 class BitmapPlatformDeviceData; | 66 class BitmapPlatformDeviceData; |
| 66 | 67 |
| 67 BitmapPlatformDevice(BitmapPlatformDeviceData* data, | 68 BitmapPlatformDevice(const skia::RefPtr<BitmapPlatformDeviceData>& data, |
| 68 const SkBitmap& bitmap); | 69 const SkBitmap& bitmap); |
| 69 | 70 |
| 70 // Flushes the CoreGraphics context so that the pixel data can be accessed | 71 // Flushes the CoreGraphics context so that the pixel data can be accessed |
| 71 // directly by Skia. Overridden from SkDevice, this is called when Skia | 72 // directly by Skia. Overridden from SkDevice, this is called when Skia |
| 72 // starts accessing pixel data. | 73 // starts accessing pixel data. |
| 73 virtual const SkBitmap& onAccessBitmap(SkBitmap*) OVERRIDE; | 74 virtual const SkBitmap& onAccessBitmap(SkBitmap*) OVERRIDE; |
| 74 | 75 |
| 75 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 76 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
| 76 int height, bool isOpaque, | 77 int height, bool isOpaque, |
| 77 Usage usage) OVERRIDE; | 78 Usage usage) OVERRIDE; |
| 78 | 79 |
| 79 // Data associated with this device, guaranteed non-null. We hold a reference | 80 // Data associated with this device, guaranteed non-null. |
| 80 // to this object. | 81 skia::RefPtr<BitmapPlatformDeviceData> data_; |
| 81 BitmapPlatformDeviceData* data_; | |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 83 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace skia | 86 } // namespace skia |
| 87 | 87 |
| 88 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 88 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
| OLD | NEW |