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

Side by Side Diff: skia/ext/bitmap_platform_device_win.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, 3 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_mac.cc ('k') | 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) 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 "base/compiler_specific.h" 10 #include "skia/ext/platform_device_win.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 Windows can also write 15 // SkCanvas to draw into. Our device provides a surface Windows can also write
17 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a 16 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a
18 // 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.
19 // 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
20 // can be shared. 19 // 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 SK_API BitmapPlatformDevice : public PlatformDevice, public SkDevice { 28 class SK_API BitmapPlatformDevice : public PlatformDevice {
30 public: 29 public:
31 // 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
32 // 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
33 // knows the bitmap will be completely opaque and allows some optimizations. 32 // knows the bitmap will be completely opaque and allows some optimizations.
34 // 33 //
35 // The shared_section parameter is optional (pass NULL for default behavior). 34 // The shared_section parameter is optional (pass NULL for default behavior).
36 // 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
37 // object returned by CreateFileMapping. See CreateDIBSection for details. 36 // object returned by CreateFileMapping. See CreateDIBSection for details.
38 static BitmapPlatformDevice* create(HDC screen_dc, int width, int height, 37 static BitmapPlatformDevice* create(HDC screen_dc,
39 bool is_opaque, HANDLE shared_section); 38 int width,
39 int height,
40 bool is_opaque,
41 HANDLE shared_section);
40 42
41 // This version is the same as above but will get the screen DC itself. 43 // This version is the same as above but will get the screen DC itself.
42 static BitmapPlatformDevice* create(int width, int height, bool is_opaque, 44 static BitmapPlatformDevice* create(int width,
45 int height,
46 bool is_opaque,
43 HANDLE shared_section); 47 HANDLE shared_section);
44 48
45 virtual ~BitmapPlatformDevice(); 49 virtual ~BitmapPlatformDevice();
46 50
47 // PlatformDevice overrides 51 // PlatformDevice overrides
48 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The 52 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The
49 // bitmap DC is lazy created. 53 // bitmap DC is lazy created.
50 virtual PlatformSurface BeginPlatformPaint() OVERRIDE; 54 virtual PlatformSurface BeginPlatformPaint();
51 virtual void EndPlatformPaint() OVERRIDE; 55 virtual void EndPlatformPaint();
52 56
53 virtual void DrawToNativeContext(HDC dc, int x, int y, 57 virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect);
54 const RECT* src_rect) OVERRIDE; 58 virtual void MakeOpaque(int x, int y, int width, int height);
55 virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE;
56 59
57 // Loads the given transform and clipping region into the HDC. This is 60 // Loads the given transform and clipping region into the HDC. This is
58 // overridden from SkDevice. 61 // overridden from SkDevice.
59 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, 62 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
60 const SkClipStack&) OVERRIDE; 63 const SkClipStack&);
61 64
62 protected: 65 protected:
63 // Flushes the Windows device context so that the pixel data can be accessed 66 // Flushes the Windows device context so that the pixel data can be accessed
64 // directly by Skia. Overridden from SkDevice, this is called when Skia 67 // directly by Skia. Overridden from SkDevice, this is called when Skia
65 // starts accessing pixel data. 68 // starts accessing pixel data.
66 virtual void onAccessBitmap(SkBitmap* bitmap) OVERRIDE; 69 virtual void onAccessBitmap(SkBitmap* bitmap);
67 70
68 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, 71 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width,
69 int height, bool isOpaque, 72 int height, bool isOpaque,
70 Usage usage) OVERRIDE; 73 Usage usage);
71 74
72 private: 75 private:
73 // Reference counted data that can be shared between multiple devices. This 76 // Reference counted data that can be shared between multiple devices. This
74 // allows copy constructors and operator= for devices to work properly. The 77 // allows copy constructors and operator= for devices to work properly. The
75 // bitmaps used by the base device class are already refcounted and copyable. 78 // bitmaps used by the base device class are already refcounted and copyable.
76 class BitmapPlatformDeviceData; 79 class BitmapPlatformDeviceData;
77 80
78 // Private constructor. The data should already be ref'ed for us. 81 // Private constructor. The data should already be ref'ed for us.
79 BitmapPlatformDevice(BitmapPlatformDeviceData* data, 82 BitmapPlatformDevice(BitmapPlatformDeviceData* data,
80 const SkBitmap& bitmap); 83 const SkBitmap& bitmap);
81 84
82 // Data associated with this device, guaranteed non-null. We hold a reference 85 // Data associated with this device, guaranteed non-null. We hold a reference
83 // to this object. 86 // to this object.
84 BitmapPlatformDeviceData* data_; 87 BitmapPlatformDeviceData* data_;
85 88
86 #ifdef SK_DEBUG 89 #ifdef SK_DEBUG
87 int begin_paint_count_; 90 int begin_paint_count_;
88 #endif 91 #endif
89 92
90 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 93 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
91 }; 94 };
92 95
93 } // namespace skia 96 } // namespace skia
94 97
95 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ 98 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
99
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_mac.cc ('k') | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698