Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: skia/ext/bitmap_platform_device_mac.h

Issue 7754001: Revert 98230 - CL removing inheritance of SkDevice from PlatformDevice. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/ext/bitmap_platform_device_linux.cc ('k') | skia/ext/bitmap_platform_device_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/compiler_specific.h" 10 #include "skia/ext/platform_device_mac.h"
11 #include "skia/ext/platform_device.h"
12 11
13 namespace skia { 12 namespace skia {
14 13
15 // 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
16 // 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
17 // write to. BitmapPlatformDevice creates a bitmap using 16 // write to. BitmapPlatformDevice creates a bitmap using
18 // 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
19 // 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
20 // device contains so that it can be shared. 19 // device contains so that it can be shared.
21 // 20 //
22 // 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
23 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses 22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses
24 // 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
25 // 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.
26 // 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
27 // 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
28 // 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.
29 class BitmapPlatformDevice : public PlatformDevice, public SkDevice { 28 class BitmapPlatformDevice : public PlatformDevice {
30 public: 29 public:
31 // |context| may be NULL. 30 // |context| may be NULL.
32 static BitmapPlatformDevice* Create(CGContextRef context, 31 static BitmapPlatformDevice* Create(CGContextRef context,
33 int width, int height, 32 int width, int height,
34 bool is_opaque); 33 bool is_opaque);
35 34
36 // Creates a context for |data| and calls Create. 35 // Creates a context for |data| and calls Create.
37 static BitmapPlatformDevice* CreateWithData(uint8_t* data, 36 static BitmapPlatformDevice* CreateWithData(uint8_t* data,
38 int width, int height, 37 int width, int height,
39 bool is_opaque); 38 bool is_opaque);
40 39
41 virtual ~BitmapPlatformDevice(); 40 virtual ~BitmapPlatformDevice();
42 41
43 // PlatformDevice overrides 42 // PlatformDevice overrides
44 virtual CGContextRef GetBitmapContext(); 43 virtual CGContextRef GetBitmapContext();
45 virtual void DrawToNativeContext(CGContextRef context, int x, int y, 44 virtual void DrawToNativeContext(CGContextRef context, int x, int y,
46 const CGRect* src_rect) OVERRIDE; 45 const CGRect* src_rect);
47 virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE; 46 virtual void MakeOpaque(int x, int y, int width, int height);
48 47
49 // SkDevice overrides 48 // SkDevice overrides
50 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, 49 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
51 const SkClipStack&) OVERRIDE; 50 const SkClipStack&);
52 51
53 protected: 52 protected:
54 // Reference counted data that can be shared between multiple devices. This 53 // Reference counted data that can be shared between multiple devices. This
55 // allows copy constructors and operator= for devices to work properly. The 54 // allows copy constructors and operator= for devices to work properly. The
56 // bitmaps used by the base device class are already refcounted and copyable. 55 // bitmaps used by the base device class are already refcounted and copyable.
57 class BitmapPlatformDeviceData; 56 class BitmapPlatformDeviceData;
58 57
59 BitmapPlatformDevice(BitmapPlatformDeviceData* data, 58 BitmapPlatformDevice(BitmapPlatformDeviceData* data,
60 const SkBitmap& bitmap); 59 const SkBitmap& bitmap);
61 60
62 // 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
63 // directly by Skia. Overridden from SkDevice, this is called when Skia 62 // directly by Skia. Overridden from SkDevice, this is called when Skia
64 // starts accessing pixel data. 63 // starts accessing pixel data.
65 virtual void onAccessBitmap(SkBitmap*) OVERRIDE; 64 virtual void onAccessBitmap(SkBitmap*);
66 65
67 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, 66 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width,
68 int height, bool isOpaque, 67 int height, bool isOpaque,
69 Usage usage) OVERRIDE; 68 Usage usage);
70 69
71 // 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
72 // to this object. 71 // to this object.
73 BitmapPlatformDeviceData* data_; 72 BitmapPlatformDeviceData* data_;
74 73
75 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 74 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
76 }; 75 };
77 76
78 } // namespace skia 77 } // namespace skia
79 78
80 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ 79 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_linux.cc ('k') | skia/ext/bitmap_platform_device_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698