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

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

Issue 1839113002: Limit manual control of platform painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "skia/ext/platform_canvas.h"
10 #include "skia/ext/platform_device.h" 11 #include "skia/ext/platform_device.h"
11 #include "skia/ext/refptr.h" 12 #include "skia/ext/refptr.h"
12 13
13 namespace skia { 14 namespace skia {
14 15
15 // A device is basically a wrapper around SkBitmap that provides a surface for 16 // 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 17 // SkCanvas to draw into. Our device provides a surface Windows can also write
17 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a 18 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a
18 // format that Skia supports and can then use this to draw ClearType into, etc. 19 // 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 20 // This pixel data is provided to the bitmap that the device contains so that it
(...skipping 11 matching lines...) Expand all
31 static BitmapPlatformDevice* Create(int width, int height, 32 static BitmapPlatformDevice* Create(int width, int height,
32 bool is_opaque, HANDLE shared_section, 33 bool is_opaque, HANDLE shared_section,
33 bool do_clear = false); 34 bool do_clear = false);
34 35
35 // Create a BitmapPlatformDevice with no shared section. The bitmap is not 36 // Create a BitmapPlatformDevice with no shared section. The bitmap is not
36 // initialized to 0. 37 // initialized to 0.
37 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); 38 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
38 39
39 ~BitmapPlatformDevice() override; 40 ~BitmapPlatformDevice() override;
40 41
41 // PlatformDevice overrides 42 // Loads (lazily) the given transform and clipping region into the HDC. This
42 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The 43 // is overridden from SkBaseDevice, where it is deprecated.
43 // bitmap DC is lazy created.
44 PlatformSurface BeginPlatformPaint() override;
45 void EndPlatformPaint() override;
46
47 // Loads the given transform and clipping region into the HDC. This is
48 // overridden from SkBaseDevice.
49 void setMatrixClip(const SkMatrix& transform, 44 void setMatrixClip(const SkMatrix& transform,
50 const SkRegion& region, 45 const SkRegion& region,
51 const SkClipStack&) override; 46 const SkClipStack&) override;
52 47
53 void DrawToHDC(HDC dc, int x, int y, const RECT* src_rect) override; 48 void DrawToHDC(HDC dc, int x, int y, const RECT* src_rect) override;
54 49
55 protected: 50 protected:
51 // PlatformDevice overrides
52 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The
53 // bitmap DC may be lazily created.
54 PlatformSurface BeginPlatformPaint() override;
55
56 // Flushes the Windows device context so that the pixel data can be accessed 56 // Flushes the Windows device context so that the pixel data can be accessed
57 // directly by Skia. Overridden from SkBaseDevice, this is called when Skia 57 // directly by Skia. Overridden from SkBaseDevice, this is called when Skia
58 // starts accessing pixel data. 58 // starts accessing pixel data.
59 const SkBitmap& onAccessBitmap() override; 59 const SkBitmap& onAccessBitmap() override;
60 60
61 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; 61 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
62 62
63 private: 63 private:
64 // Private constructor. 64 // Private constructor.
65 BitmapPlatformDevice(HBITMAP hbitmap, const SkBitmap& bitmap); 65 BitmapPlatformDevice(HBITMAP hbitmap, const SkBitmap& bitmap);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // Sets the transform and clip operations. This will not update the DC, 97 // Sets the transform and clip operations. This will not update the DC,
98 // but will mark the config as dirty. The next call of LoadConfig will 98 // but will mark the config as dirty. The next call of LoadConfig will
99 // pick up these changes. 99 // pick up these changes.
100 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); 100 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
101 101
102 // Loads the current transform and clip into the context. Can be called even 102 // Loads the current transform and clip into the context. Can be called even
103 // when |hbitmap_| is NULL (will be a NOP). 103 // when |hbitmap_| is NULL (will be a NOP).
104 void LoadConfig(); 104 void LoadConfig();
105 105
106 #ifdef SK_DEBUG 106 #ifdef SK_DEBUG
107 int begin_paint_count_; 107 int begin_paint_count_;
f(malita) 2016/03/29 17:31:07 Nit: no longer used?
tomhudson 2016/03/29 17:47:31 Done.
108 #endif 108 #endif
109 109
110 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 110 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
111 friend class skia::ScopedPlatformPaint;
111 }; 112 };
112 113
113 } // namespace skia 114 } // namespace skia
114 115
115 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ 116 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698