OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 public: | 66 public: |
67 // For printing, there shouldn't be any canvas. canvas can be NULL. If you | 67 // For printing, there shouldn't be any canvas. canvas can be NULL. If you |
68 // supply a NULL canvas, you can also call setCanvas later. | 68 // supply a NULL canvas, you can also call setCanvas later. |
69 PlatformContextSkia(skia::PlatformCanvas*); | 69 PlatformContextSkia(skia::PlatformCanvas*); |
70 ~PlatformContextSkia(); | 70 ~PlatformContextSkia(); |
71 | 71 |
72 // Sets the canvas associated with this context. Use when supplying NULL | 72 // Sets the canvas associated with this context. Use when supplying NULL |
73 // to the constructor. | 73 // to the constructor. |
74 void setCanvas(skia::PlatformCanvas*); | 74 void setCanvas(skia::PlatformCanvas*); |
75 | 75 |
| 76 #if PLATFORM(WIN_OS) |
| 77 // If false we're rendering to a GraphicsContext for a web page, if false |
| 78 // we're not (as is the case when rendering to a canvas object). |
| 79 // If this is true the contents have not been marked up with the magic |
| 80 // color and all text drawing needs to go to a layer so that the alpha is |
| 81 // correctly updated. |
| 82 void setDrawingToImageBuffer(bool value); |
| 83 bool isDrawingToImageBuffer() const; |
| 84 #endif |
| 85 |
76 void save(); | 86 void save(); |
77 void restore(); | 87 void restore(); |
78 | 88 |
| 89 // Begins a layer that is clipped to the image |imageBuffer| at the location |
| 90 // |rect|. This layer is implicitly restored when the next restore is |
| 91 // invoked. |
| 92 // NOTE: |imageBuffer| may be deleted before the |restore| is invoked. |
| 93 #if defined(__linux__) || PLATFORM(WIN_OS) |
| 94 void beginLayerClippedToImage(const WebCore::FloatRect& rect, |
| 95 const WebCore::ImageBuffer* imageBuffer); |
| 96 #endif |
| 97 |
79 // Sets up the common flags on a paint for antialiasing, effects, etc. | 98 // Sets up the common flags on a paint for antialiasing, effects, etc. |
80 // This is implicitly called by setupPaintFill and setupPaintStroke, but | 99 // This is implicitly called by setupPaintFill and setupPaintStroke, but |
81 // you may wish to call it directly sometimes if you don't want that other | 100 // you may wish to call it directly sometimes if you don't want that other |
82 // behavior. | 101 // behavior. |
83 void setupPaintCommon(SkPaint*) const; | 102 void setupPaintCommon(SkPaint*) const; |
84 | 103 |
85 // Sets up the paint for the current fill style. | 104 // Sets up the paint for the current fill style. |
86 void setupPaintForFilling(SkPaint*) const; | 105 void setupPaintForFilling(SkPaint*) const; |
87 | 106 |
88 // Sets up the paint for stroking. Returns an int representing the width of | 107 // Sets up the paint for stroking. Returns an int representing the width of |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // context. Bitmap shouldn't be resampled when printing to keep the best | 161 // context. Bitmap shouldn't be resampled when printing to keep the best |
143 // possible quality. | 162 // possible quality. |
144 bool isPrinting(); | 163 bool isPrinting(); |
145 | 164 |
146 #if defined(__linux__) | 165 #if defined(__linux__) |
147 // FIXME: should be camelCase. | 166 // FIXME: should be camelCase. |
148 GdkSkia* gdk_skia() const { return m_gdkskia; } | 167 GdkSkia* gdk_skia() const { return m_gdkskia; } |
149 #endif | 168 #endif |
150 | 169 |
151 private: | 170 private: |
| 171 #if defined(__linux__) || PLATFORM(WIN_OS) |
| 172 // Used when restoring and the state has an image clip. Only shows the pixel
s in |
| 173 // m_canvas that are also in imageBuffer. |
| 174 void applyClipFromImage(const WebCore::FloatRect& rect, const SkBitmap& imag
eBuffer); |
| 175 #endif |
| 176 |
152 // Defines drawing style. | 177 // Defines drawing style. |
153 struct State; | 178 struct State; |
154 | 179 |
155 // NULL indicates painting is disabled. Never delete this object. | 180 // NULL indicates painting is disabled. Never delete this object. |
156 skia::PlatformCanvas* m_canvas; | 181 skia::PlatformCanvas* m_canvas; |
157 | 182 |
158 // States stack. Enables local drawing state change with save()/restore() | 183 // States stack. Enables local drawing state change with save()/restore() |
159 // calls. | 184 // calls. |
160 WTF::Vector<State> m_stateStack; | 185 WTF::Vector<State> m_stateStack; |
161 // Pointer to the current drawing state. This is a cached value of | 186 // Pointer to the current drawing state. This is a cached value of |
162 // mStateStack.back(). | 187 // mStateStack.back(). |
163 State* m_state; | 188 State* m_state; |
164 | 189 |
165 // Current path in global coordinates. | 190 // Current path in global coordinates. |
166 SkPath m_path; | 191 SkPath m_path; |
167 | 192 |
168 #if defined(__linux__) | 193 #if defined(__linux__) |
169 // A pointer to a GDK Drawable wrapping of this Skia canvas | 194 // A pointer to a GDK Drawable wrapping of this Skia canvas |
170 GdkSkia* m_gdkskia; | 195 GdkSkia* m_gdkskia; |
171 #endif | 196 #endif |
| 197 |
| 198 #if PLATFORM(WIN_OS) |
| 199 bool m_drawingToImageBuffer; |
| 200 #endif |
172 }; | 201 }; |
173 | 202 |
174 #endif // PlatformContextSkia_h | 203 #endif // PlatformContextSkia_h |
OLD | NEW |