Chromium Code Reviews

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

Issue 6081007: Start sorting methods in class declarations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « skia/ext/convolver.h ('k') | skia/ext/vector_platform_device_linux.h » ('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) 2006-2008 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_CANVAS_H_ 5 #ifndef SKIA_EXT_PLATFORM_CANVAS_H_
6 #define SKIA_EXT_PLATFORM_CANVAS_H_ 6 #define SKIA_EXT_PLATFORM_CANVAS_H_
7 #pragma once 7 #pragma once
8 8
9 // The platform-specific device will include the necessary platform headers 9 // The platform-specific device will include the necessary platform headers
10 // to get the surface type. 10 // to get the surface type.
11 #include "skia/ext/platform_device.h" 11 #include "skia/ext/platform_device.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 13
14 namespace skia { 14 namespace skia {
15 15
16 // This class is a specialization of the regular SkCanvas that is designed to 16 // This class is a specialization of the regular SkCanvas that is designed to
17 // work with a PlatformDevice to manage platform-specific drawing. It allows 17 // work with a PlatformDevice to manage platform-specific drawing. It allows
18 // using both Skia operations and platform-specific operations. 18 // using both Skia operations and platform-specific operations.
19 class PlatformCanvas : public SkCanvas { 19 class PlatformCanvas : public SkCanvas {
20 public: 20 public:
21 // If you use the version with no arguments, you MUST call initialize() 21 // If you use the version with no arguments, you MUST call initialize()
22 PlatformCanvas(); 22 PlatformCanvas();
23 explicit PlatformCanvas(SkDeviceFactory* factory); 23 explicit PlatformCanvas(SkDeviceFactory* factory);
24 // Set is_opaque if you are going to erase the bitmap and not use 24 // Set is_opaque if you are going to erase the bitmap and not use
25 // transparency: this will enable some optimizations. 25 // transparency: this will enable some optimizations.
26 PlatformCanvas(int width, int height, bool is_opaque); 26 PlatformCanvas(int width, int height, bool is_opaque);
27 virtual ~PlatformCanvas();
28 27
29 #if defined(WIN32) 28 #if defined(WIN32)
30 // Windows ------------------------------------------------------------------
31
32 // The shared_section parameter is passed to gfx::PlatformDevice::create. 29 // The shared_section parameter is passed to gfx::PlatformDevice::create.
33 // See it for details. 30 // See it for details.
34 PlatformCanvas(int width, int height, bool is_opaque, HANDLE shared_section); 31 PlatformCanvas(int width, int height, bool is_opaque, HANDLE shared_section);
35
36 // For two-part init, call if you use the no-argument constructor above. Note
37 // that we want this to optionally match the Linux initialize if you only
38 // pass 3 arguments, hence the evil default argument.
39 bool initialize(int width, int height, bool is_opaque,
40 HANDLE shared_section = NULL);
41
42 #elif defined(__APPLE__) 32 #elif defined(__APPLE__)
43 // Mac -----------------------------------------------------------------------
44
45 PlatformCanvas(int width, int height, bool is_opaque, 33 PlatformCanvas(int width, int height, bool is_opaque,
46 CGContextRef context); 34 CGContextRef context);
47 PlatformCanvas(int width, int height, bool is_opaque, uint8_t* context); 35 PlatformCanvas(int width, int height, bool is_opaque, uint8_t* context);
48
49 // For two-part init, call if you use the no-argument constructor above
50 bool initialize(CGContextRef context, int width, int height, bool is_opaque);
51 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL);
52
53 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ 36 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
54 defined(__Solaris__) 37 defined(__Solaris__)
55 // Linux --------------------------------------------------------------------- 38 // Linux ---------------------------------------------------------------------
56 39
57 // Construct a canvas from the given memory region. The memory is not cleared 40 // Construct a canvas from the given memory region. The memory is not cleared
58 // first. @data must be, at least, @height * StrideForWidth(@width) bytes. 41 // first. @data must be, at least, @height * StrideForWidth(@width) bytes.
59 PlatformCanvas(int width, int height, bool is_opaque, uint8_t* data); 42 PlatformCanvas(int width, int height, bool is_opaque, uint8_t* data);
43 #endif
60 44
45 virtual ~PlatformCanvas();
46
47 #if defined(WIN32)
48 // For two-part init, call if you use the no-argument constructor above. Note
49 // that we want this to optionally match the Linux initialize if you only
50 // pass 3 arguments, hence the evil default argument.
51 bool initialize(int width, int height, bool is_opaque,
52 HANDLE shared_section = NULL);
53 #elif defined(__APPLE__)
54 // For two-part init, call if you use the no-argument constructor above
55 bool initialize(CGContextRef context, int width, int height, bool is_opaque);
56 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL);
57
58 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
59 defined(__Solaris__)
61 // For two-part init, call if you use the no-argument constructor above 60 // For two-part init, call if you use the no-argument constructor above
62 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); 61 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL);
62 #endif
63 63
64 #endif
65 // Shared -------------------------------------------------------------------- 64 // Shared --------------------------------------------------------------------
66 65
67 // These calls should surround calls to platform drawing routines, the 66 // These calls should surround calls to platform drawing routines, the
68 // surface returned here can be used with the native platform routines 67 // surface returned here can be used with the native platform routines
69 // 68 //
70 // Call endPlatformPaint when you are done and want to use Skia operations 69 // Call endPlatformPaint when you are done and want to use Skia operations
71 // after calling the platform-specific beginPlatformPaint; this will 70 // after calling the platform-specific beginPlatformPaint; this will
72 // synchronize the bitmap to OS if necessary. 71 // synchronize the bitmap to OS if necessary.
73 PlatformDevice::PlatformSurface beginPlatformPaint(); 72 PlatformDevice::PlatformSurface beginPlatformPaint();
74 void endPlatformPaint(); 73 void endPlatformPaint();
(...skipping 17 matching lines...)
92 // we use 32-bits per pixel, this will be roughly 4*width. However, for 91 // we use 32-bits per pixel, this will be roughly 4*width. However, for
93 // alignment reasons we may wish to increase that. 92 // alignment reasons we may wish to increase that.
94 static size_t StrideForWidth(unsigned width); 93 static size_t StrideForWidth(unsigned width);
95 94
96 // Allow callers to see the non-virtual function even though we have an 95 // Allow callers to see the non-virtual function even though we have an
97 // override of a virtual one. 96 // override of a virtual one.
98 // FIXME(brettw) is this necessary? 97 // FIXME(brettw) is this necessary?
99 using SkCanvas::clipRect; 98 using SkCanvas::clipRect;
100 99
101 private: 100 private:
101 // Helper method used internally by the initialize() methods.
102 bool initializeWithDevice(SkDevice* device);
103
102 // Unimplemented. This is to try to prevent people from calling this function 104 // Unimplemented. This is to try to prevent people from calling this function
103 // on SkCanvas. SkCanvas' version is not virtual, so we can't prevent this 105 // on SkCanvas. SkCanvas' version is not virtual, so we can't prevent this
104 // 100%, but hopefully this will make people notice and not use the function. 106 // 100%, but hopefully this will make people notice and not use the function.
105 // Calling SkCanvas' version will create a new device which is not compatible 107 // Calling SkCanvas' version will create a new device which is not compatible
106 // with us and we will crash if somebody tries to draw into it with 108 // with us and we will crash if somebody tries to draw into it with
107 // CoreGraphics. 109 // CoreGraphics.
108 virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap); 110 virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap);
109 111
110 // Helper method used internally by the initialize() methods.
111 bool initializeWithDevice(SkDevice* device);
112
113 // Disallow copy and assign. 112 // Disallow copy and assign.
114 PlatformCanvas(const PlatformCanvas&); 113 PlatformCanvas(const PlatformCanvas&);
115 PlatformCanvas& operator=(const PlatformCanvas&); 114 PlatformCanvas& operator=(const PlatformCanvas&);
116 }; 115 };
117 116
118 } // namespace skia 117 } // namespace skia
119 118
120 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ 119 #endif // SKIA_EXT_PLATFORM_CANVAS_H_
OLDNEW
« no previous file with comments | « skia/ext/convolver.h ('k') | skia/ext/vector_platform_device_linux.h » ('j') | no next file with comments »

Powered by Google App Engine