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/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: '' 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
« no previous file with comments | « skia/ext/platform_device_mac.cc ('k') | skia/ext/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SKIA_EXT_PLATFORM_DEVICE_WIN_H_
6 #define SKIA_EXT_PLATFORM_DEVICE_WIN_H_
7 #pragma once
8
9 #include <windows.h>
10
11 #include <vector>
12
13 #include "third_party/skia/include/core/SkDevice.h"
14
15 class SkMatrix;
16 class SkPath;
17 class SkRegion;
18
19 namespace skia {
20
21 // Initializes the default settings and colors in a device context.
22 SK_API void InitializeDC(HDC context);
23
24 // A device 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
26 // to. It also provides functionality to play well with GDI drawing functions.
27 // This class is abstract and must be subclassed. It provides the basic
28 // interface to implement it either with or without a bitmap backend.
29 class SK_API PlatformDevice : public SkDevice {
30 public:
31 typedef HDC PlatformSurface;
32
33 // 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
35 // only during one pass of rendering.
36 virtual PlatformSurface BeginPlatformPaint() = 0;
37
38 // Finish a previous call to beginPlatformPaint.
39 virtual void EndPlatformPaint();
40
41 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will
42 // temporarily create it. However, if you have created the bitmap DC, it will
43 // be more efficient if you don't free it until after this call so it doesn't
44 // have to be created twice. If src_rect is null, then the entirety of the
45 // source device will be copied.
46 virtual void DrawToNativeContext(HDC dc, int x, int y,
47 const RECT* src_rect) = 0;
48
49 // Sets the opacity of each pixel in the specified region to be opaque.
50 virtual void MakeOpaque(int x, int y, int width, int height) { }
51
52 // Returns if GDI is allowed to render text to this device.
53 virtual bool IsNativeFontRenderingAllowed() { return true; }
54
55 // True if AlphaBlend() was called during a
56 // BeginPlatformPaint()/EndPlatformPaint() pair.
57 // Used by the printing subclasses. See |VectorPlatformDeviceEmf|.
58 virtual bool AlphaBlendUsed() const { return false; }
59
60 // 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.
62 static bool LoadPathToDC(HDC context, const SkPath& path);
63
64 // Loads a SkRegion into the GDI context.
65 static void LoadClippingRegionToDC(HDC context, const SkRegion& region,
66 const SkMatrix& transformation);
67
68 protected:
69 // Arrays must be inside structures.
70 struct CubicPoints {
71 SkPoint p[4];
72 };
73 typedef std::vector<CubicPoints> CubicPath;
74 typedef std::vector<CubicPath> CubicPaths;
75
76 // Forwards |bitmap| to SkDevice's constructor.
77 PlatformDevice(const SkBitmap& bitmap);
78
79 // Loads the specified Skia transform into the device context, excluding
80 // perspective (which GDI doesn't support).
81 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix);
82
83 // Transforms SkPath's paths into a series of cubic path.
84 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath);
85 };
86
87 } // namespace skia
88
89 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_
90
OLDNEW
« no previous file with comments | « skia/ext/platform_device_mac.cc ('k') | skia/ext/platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698