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

Side by Side Diff: skia/ext/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_PLATFORM_DEVICE_WIN_H_ 5 #ifndef SKIA_EXT_PLATFORM_DEVICE_WIN_H_
6 #define SKIA_EXT_PLATFORM_DEVICE_WIN_H_ 6 #define SKIA_EXT_PLATFORM_DEVICE_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "third_party/skia/include/core/SkDevice.h" 13 #include "third_party/skia/include/core/SkDevice.h"
14 14
15 class SkMatrix; 15 class SkMatrix;
16 class SkPath; 16 class SkPath;
17 class SkRegion; 17 class SkRegion;
18 18
19 namespace skia { 19 namespace skia {
20 20
21 // Initializes the default settings and colors in a device context. 21 // Initializes the default settings and colors in a device context.
22 SK_API void InitializeDC(HDC context); 22 SK_API void InitializeDC(HDC context);
23 23
24 // A device is basically a wrapper around SkBitmap that provides a surface for 24 // A SkDevice is basically a wrapper around SkBitmap that provides a surface for
25 // SkCanvas to draw into. Our device provides a surface Windows can also write 25 // SkCanvas to draw into. PlatformDevice provides a surface Windows can also
26 // to. It also provides functionality to play well with GDI drawing functions. 26 // write to. It also provides functionality to play well with GDI drawing
27 // This class is abstract and must be subclassed. It provides the basic 27 // functions. This class is abstract and must be subclassed. It provides the bas ic
28 // interface to implement it either with or without a bitmap backend. 28 // interface to implement it either with or without a bitmap backend.
29 class SK_API PlatformDevice : public SkDevice { 29 //
30 // PlatformDevice provides an interface which sub-classes of SkDevice can also
31 // provide to allow for drawing by the native platform into the device.
32 class SK_API PlatformDevice {
30 public: 33 public:
31 typedef HDC PlatformSurface; 34 typedef HDC PlatformSurface;
32 35
33 // The DC that corresponds to the bitmap, used for GDI operations drawing 36 // The DC that corresponds to the bitmap, used for GDI operations drawing
34 // into the bitmap. This is possibly heavyweight, so it should be existant 37 // into the bitmap. This is possibly heavyweight, so it should be existant
35 // only during one pass of rendering. 38 // only during one pass of rendering.
36 virtual PlatformSurface BeginPlatformPaint() = 0; 39 virtual PlatformSurface BeginPlatformPaint() = 0;
37 40
38 // Finish a previous call to beginPlatformPaint. 41 // Finish a previous call to beginPlatformPaint.
39 virtual void EndPlatformPaint(); 42 virtual void EndPlatformPaint();
(...skipping 10 matching lines...) Expand all
50 virtual void MakeOpaque(int x, int y, int width, int height) { } 53 virtual void MakeOpaque(int x, int y, int width, int height) { }
51 54
52 // Returns if GDI is allowed to render text to this device. 55 // Returns if GDI is allowed to render text to this device.
53 virtual bool IsNativeFontRenderingAllowed() { return true; } 56 virtual bool IsNativeFontRenderingAllowed() { return true; }
54 57
55 // True if AlphaBlend() was called during a 58 // True if AlphaBlend() was called during a
56 // BeginPlatformPaint()/EndPlatformPaint() pair. 59 // BeginPlatformPaint()/EndPlatformPaint() pair.
57 // Used by the printing subclasses. See |VectorPlatformDeviceEmf|. 60 // Used by the printing subclasses. See |VectorPlatformDeviceEmf|.
58 virtual bool AlphaBlendUsed() const { return false; } 61 virtual bool AlphaBlendUsed() const { return false; }
59 62
63 // Return the SkDevice instance which is associated with this PlatformDevice.
64 SkDevice* GetOwningDevice() const { return device_; }
65
60 // Loads a SkPath into the GDI context. The path can there after be used for 66 // Loads a SkPath into the GDI context. The path can there after be used for
61 // clipping or as a stroke. Returns false if the path failed to be loaded. 67 // clipping or as a stroke. Returns false if the path failed to be loaded.
62 static bool LoadPathToDC(HDC context, const SkPath& path); 68 static bool LoadPathToDC(HDC context, const SkPath& path);
63 69
64 // Loads a SkRegion into the GDI context. 70 // Loads a SkRegion into the GDI context.
65 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, 71 static void LoadClippingRegionToDC(HDC context, const SkRegion& region,
66 const SkMatrix& transformation); 72 const SkMatrix& transformation);
67 73
68 protected: 74 protected:
69 // Arrays must be inside structures. 75 // Arrays must be inside structures.
70 struct CubicPoints { 76 struct CubicPoints {
71 SkPoint p[4]; 77 SkPoint p[4];
72 }; 78 };
73 typedef std::vector<CubicPoints> CubicPath; 79 typedef std::vector<CubicPoints> CubicPath;
74 typedef std::vector<CubicPath> CubicPaths; 80 typedef std::vector<CubicPath> CubicPaths;
75 81
76 // Forwards |bitmap| to SkDevice's constructor. 82 explicit PlatformDevice(SkDevice* device);
77 PlatformDevice(const SkBitmap& bitmap);
78 83
79 // Loads the specified Skia transform into the device context, excluding 84 // Loads the specified Skia transform into the device context, excluding
80 // perspective (which GDI doesn't support). 85 // perspective (which GDI doesn't support).
81 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); 86 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix);
82 87
83 // Transforms SkPath's paths into a series of cubic path. 88 // Transforms SkPath's paths into a series of cubic path.
84 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); 89 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath);
90
91 // The device to which the PlatformDevice interface is bound.
92 SkDevice* device_;
85 }; 93 };
86 94
87 } // namespace skia 95 } // namespace skia
88 96
89 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_ 97 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_
90
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698