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

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

Issue 125109: Refactor the PlatformContext layer to have only one class. (Closed)
Patch Set: Created 11 years, 6 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
« no previous file with comments | « skia/ext/platform_device_linux.cc ('k') | skia/ext/platform_device_mac.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_MAC_H_ 5 #ifndef SKIA_EXT_PLATFORM_DEVICE_MAC_H_
6 #define SKIA_EXT_PLATFORM_DEVICE_MAC_H_ 6 #define SKIA_EXT_PLATFORM_DEVICE_MAC_H_
7 7
8 #import <ApplicationServices/ApplicationServices.h> 8 #import <ApplicationServices/ApplicationServices.h>
9 #include "third_party/skia/include/core/SkDevice.h" 9 #include "third_party/skia/include/core/SkDevice.h"
10 10
11 class SkMatrix; 11 class SkMatrix;
12 class SkPath; 12 class SkPath;
13 class SkRegion; 13 class SkRegion;
14 14
15 namespace skia { 15 namespace skia {
16 16
17 // A device is basically a wrapper around SkBitmap that provides a surface for 17 // A device is basically a wrapper around SkBitmap that provides a surface for
18 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also 18 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also
19 // write to. It also provides functionality to play well with CG drawing 19 // write to. It also provides functionality to play well with CG drawing
20 // functions. 20 // functions.
21 // This class is abstract and must be subclassed. It provides the basic 21 // This class is abstract and must be subclassed. It provides the basic
22 // interface to implement it either with or without a bitmap backend. 22 // interface to implement it either with or without a bitmap backend.
23 class PlatformDeviceMac : public SkDevice { 23 class PlatformDevice : public SkDevice {
24 public: 24 public:
25 typedef CGContextRef PlatformSurface;
26
25 // The CGContext that corresponds to the bitmap, used for CoreGraphics 27 // The CGContext that corresponds to the bitmap, used for CoreGraphics
26 // operations drawing into the bitmap. This is possibly heavyweight, so it 28 // operations drawing into the bitmap. This is possibly heavyweight, so it
27 // should exist only during one pass of rendering. 29 // should exist only during one pass of rendering.
28 virtual CGContextRef GetBitmapContext() = 0; 30 virtual CGContextRef GetBitmapContext() = 0;
29 31
30 // Draws to the given graphics context. If the bitmap context doesn't exist, 32 // Draws to the given graphics context. If the bitmap context doesn't exist,
31 // this will temporarily create it. However, if you have created the bitmap 33 // this will temporarily create it. However, if you have created the bitmap
32 // context, it will be more efficient if you don't free it until after this 34 // context, it will be more efficient if you don't free it until after this
33 // call so it doesn't have to be created twice. If src_rect is null, then 35 // call so it doesn't have to be created twice. If src_rect is null, then
34 // the entirety of the source device will be copied. 36 // the entirety of the source device will be copied.
(...skipping 10 matching lines...) Expand all
45 // clipping or as a stroke. 47 // clipping or as a stroke.
46 static void LoadPathToCGContext(CGContextRef context, const SkPath& path); 48 static void LoadPathToCGContext(CGContextRef context, const SkPath& path);
47 49
48 // Loads a SkRegion into the CG context. 50 // Loads a SkRegion into the CG context.
49 static void LoadClippingRegionToCGContext(CGContextRef context, 51 static void LoadClippingRegionToCGContext(CGContextRef context,
50 const SkRegion& region, 52 const SkRegion& region,
51 const SkMatrix& transformation); 53 const SkMatrix& transformation);
52 54
53 protected: 55 protected:
54 // Forwards |bitmap| to SkDevice's constructor. 56 // Forwards |bitmap| to SkDevice's constructor.
55 PlatformDeviceMac(const SkBitmap& bitmap); 57 PlatformDevice(const SkBitmap& bitmap);
56 58
57 // Loads the specified Skia transform into the device context 59 // Loads the specified Skia transform into the device context
58 static void LoadTransformToCGContext(CGContextRef context, 60 static void LoadTransformToCGContext(CGContextRef context,
59 const SkMatrix& matrix); 61 const SkMatrix& matrix);
60 62
61 // Function pointer used by the processPixels method for setting the alpha 63 // Function pointer used by the processPixels method for setting the alpha
62 // value of a particular pixel. 64 // value of a particular pixel.
63 typedef void (*adjustAlpha)(uint32_t* pixel); 65 typedef void (*adjustAlpha)(uint32_t* pixel);
64 66
65 // Loops through each of the pixels in the specified range, invoking 67 // Loops through each of the pixels in the specified range, invoking
66 // adjustor for the alpha value of each pixel. 68 // adjustor for the alpha value of each pixel.
67 virtual void processPixels(int x, 69 virtual void processPixels(int x,
68 int y, 70 int y,
69 int width, 71 int width,
70 int height, 72 int height,
71 adjustAlpha adjustor) = 0; 73 adjustAlpha adjustor) = 0;
72 }; 74 };
73 75
74 } // namespace skia 76 } // namespace skia
75 77
76 #endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_ 78 #endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_
77 79
OLDNEW
« no previous file with comments | « skia/ext/platform_device_linux.cc ('k') | skia/ext/platform_device_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698