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

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

Issue 126140: Properly use data when creating a bitmap platform canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « no previous file | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "skia/ext/platform_device_mac.h" 8 #include "skia/ext/platform_device_mac.h"
9 9
10 namespace skia { 10 namespace skia {
11 11
12 // A device is basically a wrapper around SkBitmap that provides a surface for 12 // A device is basically a wrapper around SkBitmap that provides a surface for
13 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also 13 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also
14 // write to. BitmapPlatformDevice creates a bitmap using 14 // write to. BitmapPlatformDevice creates a bitmap using
15 // CGCreateBitmapContext() in a format that Skia supports and can then use this 15 // CGCreateBitmapContext() in a format that Skia supports and can then use this
16 // to draw text into, etc. This pixel data is provided to the bitmap that the 16 // to draw text into, etc. This pixel data is provided to the bitmap that the
17 // device contains so that it can be shared. 17 // device contains so that it can be shared.
18 // 18 //
19 // The device owns the pixel data, when the device goes away, the pixel data 19 // The device owns the pixel data, when the device goes away, the pixel data
20 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses 20 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses
21 // reference counting for the pixel data. In normal Skia, you could assign 21 // reference counting for the pixel data. In normal Skia, you could assign
22 // another bitmap to this device's bitmap and everything will work properly. 22 // another bitmap to this device's bitmap and everything will work properly.
23 // For us, that other bitmap will become invalid as soon as the device becomes 23 // For us, that other bitmap will become invalid as soon as the device becomes
24 // invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE 24 // invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE
25 // DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead. 25 // DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead.
26 class BitmapPlatformDevice : public PlatformDevice { 26 class BitmapPlatformDevice : public PlatformDevice {
27 public: 27 public:
28 // Factory function. The screen DC is used to create the bitmap, and will not 28 // |context| may be NULL.
29 // be stored beyond this function. is_opaque should be set if the caller 29 static BitmapPlatformDevice* CreateWithContext(CGContextRef context,
30 // knows the bitmap will be completely opaque and allows some optimizations. 30 int width, int height,
31 // 31 bool is_opaque);
32 // The shared_section parameter is optional (pass NULL for default behavior). 32
33 // If shared_section is non-null, then it must be a handle to a file-mapping 33 // Creates a context for |data| and calls CreateWithContext.
34 // object returned by CreateFileMapping. See CreateDIBSection for details. 34 static BitmapPlatformDevice* CreateWithData(uint8_t* data,
35 static BitmapPlatformDevice* Create(CGContextRef context, 35 int width, int height,
36 int width, 36 bool is_opaque);
37 int height,
38 bool is_opaque);
39 37
40 // Copy constructor. When copied, devices duplicate their internal data, so 38 // Copy constructor. When copied, devices duplicate their internal data, so
41 // stay linked. This is because their implementation is very heavyweight 39 // stay linked. This is because their implementation is very heavyweight
42 // (lots of memory and CoreGraphics state). If a device has been copied, both 40 // (lots of memory and CoreGraphics state). If a device has been copied, both
43 // clip rects and other state will stay in sync. 41 // clip rects and other state will stay in sync.
44 // 42 //
45 // This means it will NOT work to duplicate a device and assign it to a 43 // This means it will NOT work to duplicate a device and assign it to a
46 // canvas, because the two canvases will each set their own clip rects, and 44 // canvas, because the two canvases will each set their own clip rects, and
47 // the resulting CoreGraphics drawing state will be unpredictable. 45 // the resulting CoreGraphics drawing state will be unpredictable.
48 // 46 //
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 adjustAlpha adjustor); 82 adjustAlpha adjustor);
85 83
86 // Data associated with this device, guaranteed non-null. We hold a reference 84 // Data associated with this device, guaranteed non-null. We hold a reference
87 // to this object. 85 // to this object.
88 BitmapPlatformDeviceData* data_; 86 BitmapPlatformDeviceData* data_;
89 }; 87 };
90 88
91 } // namespace skia 89 } // namespace skia
92 90
93 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ 91 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698