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

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

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add mac changes. 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
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_WIN_H_ 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_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_win.h" 10 #include "skia/ext/platform_device_win.h"
11 11
12 namespace skia { 12 namespace skia {
13 13
14 // 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
15 // SkCanvas to draw into. Our device provides a surface Windows can also write 15 // SkCanvas to draw into. Our device provides a surface Windows can also write
16 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a 16 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a
17 // format that Skia supports and can then use this to draw ClearType into, etc. 17 // format that Skia supports and can then use this to draw ClearType into, etc.
18 // This pixel data is provided to the bitmap that the device contains so that it 18 // This pixel data is provided to the bitmap that the device contains so that it
19 // can be shared. 19 // can be shared.
20 // 20 //
21 // 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
22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses 22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses
23 // 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
24 // 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.
25 // 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
26 // 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
27 // 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.
28 class SK_API BitmapPlatformDevice : public PlatformDevice { 28 class SK_API BitmapPlatformDevice : public PlatformDevice, public SkDevice {
29 public: 29 public:
30 // Factory function. The screen DC is used to create the bitmap, and will not 30 // Factory function. The screen DC is used to create the bitmap, and will not
31 // be stored beyond this function. is_opaque should be set if the caller 31 // be stored beyond this function. is_opaque should be set if the caller
32 // knows the bitmap will be completely opaque and allows some optimizations. 32 // knows the bitmap will be completely opaque and allows some optimizations.
33 // 33 //
34 // The shared_section parameter is optional (pass NULL for default behavior). 34 // The shared_section parameter is optional (pass NULL for default behavior).
35 // If shared_section is non-null, then it must be a handle to a file-mapping 35 // If shared_section is non-null, then it must be a handle to a file-mapping
36 // object returned by CreateFileMapping. See CreateDIBSection for details. 36 // object returned by CreateFileMapping. See CreateDIBSection for details.
37 static BitmapPlatformDevice* create(HDC screen_dc, 37 static BitmapPlatformDevice* create(HDC screen_dc, int width, int height,
38 int width, 38 bool is_opaque, HANDLE shared_section);
39 int height,
40 bool is_opaque,
41 HANDLE shared_section);
42 39
43 // This version is the same as above but will get the screen DC itself. 40 // This version is the same as above but will get the screen DC itself.
44 static BitmapPlatformDevice* create(int width, 41 static BitmapPlatformDevice* create(int width,int height, bool is_opaque,
vandebo (ex-Chrome) 2011/08/19 21:54:22 width, int
Jeff Timanus 2011/08/20 02:31:04 Done.
45 int height,
46 bool is_opaque,
47 HANDLE shared_section); 42 HANDLE shared_section);
48 43
49 virtual ~BitmapPlatformDevice(); 44 virtual ~BitmapPlatformDevice();
50 45
51 // PlatformDevice overrides 46 // PlatformDevice overrides
52 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The 47 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The
53 // bitmap DC is lazy created. 48 // bitmap DC is lazy created.
54 virtual PlatformSurface BeginPlatformPaint(); 49 virtual PlatformSurface BeginPlatformPaint() OVERRIDE;
55 virtual void EndPlatformPaint(); 50 virtual void EndPlatformPaint() OVERRIDE;
56 51
57 virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect); 52 virtual void DrawToNativeContext(HDC dc, int x, int y,
58 virtual void MakeOpaque(int x, int y, int width, int height); 53 const RECT* src_rect) OVERRIDE;
54 virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE;
59 55
60 // Loads the given transform and clipping region into the HDC. This is 56 // Loads the given transform and clipping region into the HDC. This is
61 // overridden from SkDevice. 57 // overridden from SkDevice.
62 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, 58 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
63 const SkClipStack&); 59 const SkClipStack&) OVERRIDE;
64 60
65 protected: 61 protected:
66 // Flushes the Windows device context so that the pixel data can be accessed 62 // Flushes the Windows device context so that the pixel data can be accessed
67 // directly by Skia. Overridden from SkDevice, this is called when Skia 63 // directly by Skia. Overridden from SkDevice, this is called when Skia
68 // starts accessing pixel data. 64 // starts accessing pixel data.
69 virtual void onAccessBitmap(SkBitmap* bitmap); 65 virtual void onAccessBitmap(SkBitmap* bitmap) OVERRIDE;
70 66
71 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, 67 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width,
72 int height, bool isOpaque, 68 int height, bool isOpaque,
73 Usage usage); 69 Usage usage) OVERRIDE;
74 70
75 private: 71 private:
76 // Reference counted data that can be shared between multiple devices. This 72 // Reference counted data that can be shared between multiple devices. This
77 // allows copy constructors and operator= for devices to work properly. The 73 // allows copy constructors and operator= for devices to work properly. The
78 // bitmaps used by the base device class are already refcounted and copyable. 74 // bitmaps used by the base device class are already refcounted and copyable.
79 class BitmapPlatformDeviceData; 75 class BitmapPlatformDeviceData;
80 76
81 // Private constructor. The data should already be ref'ed for us. 77 // Private constructor. The data should already be ref'ed for us.
82 BitmapPlatformDevice(BitmapPlatformDeviceData* data, 78 BitmapPlatformDevice(BitmapPlatformDeviceData* data,
83 const SkBitmap& bitmap); 79 const SkBitmap& bitmap);
84 80
85 // Data associated with this device, guaranteed non-null. We hold a reference 81 // Data associated with this device, guaranteed non-null. We hold a reference
86 // to this object. 82 // to this object.
87 BitmapPlatformDeviceData* data_; 83 BitmapPlatformDeviceData* data_;
88 84
89 #ifdef SK_DEBUG 85 #ifdef SK_DEBUG
90 int begin_paint_count_; 86 int begin_paint_count_;
91 #endif 87 #endif
92 88
93 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 89 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
94 }; 90 };
95 91
96 } // namespace skia 92 } // namespace skia
97 93
98 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ 94 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
99
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698