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

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

Issue 14903: Reverting 7318. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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_win.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_BITMAP_PLATFORM_DEVICE_WIN_H_ 5 #ifndef SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_
6 #define SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ 6 #define SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_
7 7
8 #include "base/ref_counted.h"
9 #include "skia/ext/platform_device_win.h" 8 #include "skia/ext/platform_device_win.h"
10 9
11 namespace skia { 10 namespace skia {
12 11
13 // 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
14 // SkCanvas to draw into. Our device provides a surface Windows can also write 13 // SkCanvas to draw into. Our device provides a surface Windows can also write
15 // to. BitmapPlatformDeviceWin creates a bitmap using CreateDIBSection() in a 14 // to. BitmapPlatformDeviceWin creates a bitmap using CreateDIBSection() in a
16 // format that Skia supports and can then use this to draw ClearType into, etc. 15 // format that Skia supports and can then use this to draw ClearType into, etc.
17 // This pixel data is provided to the bitmap that the device contains so that it 16 // This pixel data is provided to the bitmap that the device contains so that it
18 // can be shared. 17 // can be shared.
19 // 18 //
20 // 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
21 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses 20 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses
22 // 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
23 // 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.
24 // 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
25 // 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
26 // 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.
27 class BitmapPlatformDeviceWin : public PlatformDeviceWin { 26 class BitmapPlatformDeviceWin : public PlatformDeviceWin {
28 public: 27 public:
29 // Factory function. The screen DC is used to create the bitmap, and will not 28 // Factory function. The screen DC is used to create the bitmap, and will not
30 // be stored beyond this function. is_opaque should be set if the caller 29 // be stored beyond this function. is_opaque should be set if the caller
31 // knows the bitmap will be completely opaque and allows some optimizations. 30 // knows the bitmap will be completely opaque and allows some optimizations.
32 // 31 //
33 // The shared_section parameter is optional (pass NULL for default behavior). 32 // The shared_section parameter is optional (pass NULL for default behavior).
34 // If shared_section is non-null, then it must be a handle to a file-mapping 33 // If shared_section is non-null, then it must be a handle to a file-mapping
35 // object returned by CreateFileMapping. See CreateDIBSection for details. 34 // object returned by CreateFileMapping. See CreateDIBSection for details.
36 static BitmapPlatformDeviceWin* create(HDC screen_dc, 35 static BitmapPlatformDeviceWin* create(HDC screen_dc,
37 int width, 36 int width,
38 int height, 37 int height,
39 bool is_opaque, 38 bool is_opaque,
40 HANDLE shared_section); 39 HANDLE shared_section);
41 40
42 // Copy constructor. When copied, devices duplicate their internal data, so 41 // Copy constructor. When copied, devices duplicate their internal data, so
43 // stay linked. This is because their implementation is very heavyweight 42 // stay linked. This is because their implementation is very heavyweight
44 // (lots of memory and some GDI objects). If a device has been copied, both 43 // (lots of memory and some GDI objects). If a device has been copied, both
45 // clip rects and other state will stay in sync. 44 // clip rects and other state will stay in sync.
46 // 45 //
47 // This means it will NOT work to duplicate a device and assign it to a 46 // This means it will NOT work to duplicate a device and assign it to a
48 // canvas, because the two canvases will each set their own clip rects, and 47 // canvas, because the two canvases will each set their own clip rects, and
49 // the resulting GDI clip rect will be random. 48 // the resulting GDI clip rect will be random.
50 // 49 //
(...skipping 30 matching lines...) Expand all
81 private: 80 private:
82 // Function pointer used by the processPixels method for setting the alpha 81 // Function pointer used by the processPixels method for setting the alpha
83 // value of a particular pixel. 82 // value of a particular pixel.
84 typedef void (*adjustAlpha)(uint32_t* pixel); 83 typedef void (*adjustAlpha)(uint32_t* pixel);
85 84
86 // Reference counted data that can be shared between multiple devices. This 85 // Reference counted data that can be shared between multiple devices. This
87 // allows copy constructors and operator= for devices to work properly. The 86 // allows copy constructors and operator= for devices to work properly. The
88 // bitmaps used by the base device class are already refcounted and copyable. 87 // bitmaps used by the base device class are already refcounted and copyable.
89 class BitmapPlatformDeviceWinData; 88 class BitmapPlatformDeviceWinData;
90 89
91 // Private constructor. 90 // Private constructor. The data should already be ref'ed for us.
92 BitmapPlatformDeviceWin(BitmapPlatformDeviceWinData* data, 91 BitmapPlatformDeviceWin(BitmapPlatformDeviceWinData* data,
93 const SkBitmap& bitmap); 92 const SkBitmap& bitmap);
94 93
95 // Loops through each of the pixels in the specified range, invoking 94 // Loops through each of the pixels in the specified range, invoking
96 // adjustor for the alpha value of each pixel. If |width| or |height| are -1, 95 // adjustor for the alpha value of each pixel. If |width| or |height| are -1,
97 // the available width/height is used. 96 // the available width/height is used.
98 template<adjustAlpha adjustor> 97 template<adjustAlpha adjustor>
99 void processPixels(int x, 98 void processPixels(int x,
100 int y, 99 int y,
101 int width, 100 int width,
102 int height); 101 int height);
103 102
104 // Data associated with this device, guaranteed non-null. 103 // Data associated with this device, guaranteed non-null. We hold a reference
105 scoped_refptr<BitmapPlatformDeviceWinData> data_; 104 // to this object.
105 BitmapPlatformDeviceWinData* data_;
106 }; 106 };
107 107
108 } // namespace skia 108 } // namespace skia
109 109
110 #endif // SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ 110 #endif // SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_
111 111
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698