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

Side by Side Diff: Source/core/platform/graphics/GraphicsContext.h

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years 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
(Empty)
1 /*
2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008-2009 Torch Mobile, Inc.
4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef GraphicsContext_h
29 #define GraphicsContext_h
30
31 #include "core/platform/graphics/Font.h"
32 #include "core/platform/graphics/GraphicsContextAnnotation.h"
33 #include "core/platform/graphics/GraphicsContextState.h"
34 #include "core/platform/graphics/ImageBuffer.h"
35 #include "core/platform/graphics/skia/OpaqueRegionSkia.h"
36 #include "core/platform/graphics/skia/SkiaUtils.h"
37 #include "platform/TraceEvent.h"
38 #include "platform/geometry/FloatRect.h"
39 #include "platform/graphics/DashArray.h"
40 #include "platform/graphics/DrawLooper.h"
41 #include "platform/graphics/ImageOrientation.h"
42 // TODO(robertphillips): replace this include with "class SkBaseDevice;"
43 #include "third_party/skia/include/core/SkDevice.h"
44 #include "wtf/FastAllocBase.h"
45 #include "wtf/Forward.h"
46 #include "wtf/Noncopyable.h"
47 #include "wtf/PassOwnPtr.h"
48
49 class SkBitmap;
50 class SkPaint;
51 class SkPath;
52 class SkRRect;
53 struct SkRect;
54
55 namespace WebCore {
56
57 class DisplayList;
58 class ImageBuffer;
59 class KURL;
60
61 class GraphicsContext {
62 WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED;
63 public:
64 enum AntiAliasingMode {
65 NotAntiAliased,
66 AntiAliased
67 };
68 enum AccessMode {
69 ReadOnly,
70 ReadWrite
71 };
72
73 explicit GraphicsContext(SkCanvas*);
74 ~GraphicsContext();
75
76 // Returns the canvas used for painting, NOT guaranteed to be non-null.
77 // Accessing the backing canvas this way flushes all queued save ops,
78 // so it should be avoided. Use the corresponding draw/matrix/clip methods i nstead.
79 SkCanvas* canvas()
80 {
81 // Flush any pending saves.
82 realizeSave(SkCanvas::kMatrixClip_SaveFlag);
83
84 return m_canvas;
85 }
86 const SkCanvas* canvas() const { return m_canvas; }
87 bool paintingDisabled() const { return !m_canvas; }
88
89 const SkBitmap* bitmap() const;
90 const SkBitmap& layerBitmap(AccessMode = ReadOnly) const;
91
92 SkBaseDevice* createCompatibleDevice(const IntSize&, bool hasAlpha) const;
93
94 // ---------- State management methods -----------------
95 void save();
96 void restore();
97
98 void saveLayer(const SkRect* bounds, const SkPaint*, SkCanvas::SaveFlags = S kCanvas::kARGB_ClipLayer_SaveFlag);
99 void restoreLayer();
100
101 float strokeThickness() const { return m_state->m_strokeData.thickness(); }
102 void setStrokeThickness(float thickness) { m_state->m_strokeData.setThicknes s(thickness); }
103
104 StrokeStyle strokeStyle() const { return m_state->m_strokeData.style(); }
105 void setStrokeStyle(StrokeStyle style) { m_state->m_strokeData.setStyle(styl e); }
106
107 Color strokeColor() const { return m_state->m_strokeData.color(); }
108 void setStrokeColor(const Color&);
109
110 Pattern* strokePattern() const { return m_state->m_strokeData.pattern(); }
111 void setStrokePattern(PassRefPtr<Pattern>);
112
113 Gradient* strokeGradient() const { return m_state->m_strokeData.gradient(); }
114 void setStrokeGradient(PassRefPtr<Gradient>);
115
116 void setLineCap(LineCap cap) { m_state->m_strokeData.setLineCap(cap); }
117 void setLineDash(const DashArray& dashes, float dashOffset) { m_state->m_str okeData.setLineDash(dashes, dashOffset); }
118 void setLineJoin(LineJoin join) { m_state->m_strokeData.setLineJoin(join); }
119 void setMiterLimit(float limit) { m_state->m_strokeData.setMiterLimit(limit) ; }
120
121 WindRule fillRule() const { return m_state->m_fillRule; }
122 void setFillRule(WindRule fillRule) { m_state->m_fillRule = fillRule; }
123
124 Color fillColor() const { return m_state->m_fillColor; }
125 void setFillColor(const Color&);
126 SkColor effectiveFillColor() const { return m_state->applyAlpha(m_state->m_f illColor.rgb()); }
127
128 void setFillPattern(PassRefPtr<Pattern>);
129 Pattern* fillPattern() const { return m_state->m_fillPattern.get(); }
130
131 void setFillGradient(PassRefPtr<Gradient>);
132 Gradient* fillGradient() const { return m_state->m_fillGradient.get(); }
133
134 SkDrawLooper* drawLooper() const { return m_state->m_looper.get(); }
135 SkColor effectiveStrokeColor() const { return m_state->applyAlpha(m_state->m _strokeData.color().rgb()); }
136
137 int getNormalizedAlpha() const;
138
139 bool getClipBounds(SkRect* bounds) const;
140 bool getTransformedClipBounds(FloatRect* bounds) const;
141 SkMatrix getTotalMatrix() const;
142 bool isPrintingDevice() const;
143
144 void setShouldAntialias(bool antialias) { m_state->m_shouldAntialias = antia lias; }
145 bool shouldAntialias() const { return m_state->m_shouldAntialias; }
146
147 void setShouldClampToSourceRect(bool clampToSourceRect) { m_state->m_shouldC lampToSourceRect = clampToSourceRect; }
148 bool shouldClampToSourceRect() const { return m_state->m_shouldClampToSource Rect; }
149
150 void setShouldSmoothFonts(bool smoothFonts) { m_state->m_shouldSmoothFonts = smoothFonts; }
151 bool shouldSmoothFonts() const { return m_state->m_shouldSmoothFonts; }
152
153 // Turn off LCD text for the paint if not supported on this context.
154 void adjustTextRenderMode(SkPaint*);
155 bool couldUseLCDRenderedText();
156
157 TextDrawingModeFlags textDrawingMode() const { return m_state->m_textDrawing Mode; }
158 void setTextDrawingMode(TextDrawingModeFlags mode) { m_state->m_textDrawingM ode = mode; }
159
160 void setAlpha(float alpha) { m_state->m_alpha = alpha; }
161
162 void setImageInterpolationQuality(InterpolationQuality quality) { m_state->m _interpolationQuality = quality; }
163 InterpolationQuality imageInterpolationQuality() const { return m_state->m_i nterpolationQuality; }
164
165 void setCompositeOperation(CompositeOperator, blink::WebBlendMode = blink::W ebBlendModeNormal);
166 CompositeOperator compositeOperation() const { return m_state->m_compositeOp erator; }
167 blink::WebBlendMode blendModeOperation() const { return m_state->m_blendMode ; }
168
169 // Change the way document markers are rendered.
170 // Any deviceScaleFactor higher than 1.5 is enough to justify setting this f lag.
171 void setUseHighResMarkers(bool isHighRes) { m_useHighResMarker = isHighRes; }
172
173 // If true we are (most likely) rendering to a web page and the
174 // canvas has been prepared with an opaque background. If false,
175 // the canvas may havbe transparency (as is the case when rendering
176 // to a canvas object).
177 void setCertainlyOpaque(bool isOpaque) { m_isCertainlyOpaque = isOpaque; }
178 bool isCertainlyOpaque() const { return m_isCertainlyOpaque; }
179
180 // Returns if the context is a printing context instead of a display
181 // context. Bitmap shouldn't be resampled when printing to keep the best
182 // possible quality.
183 bool printing() const { return m_printing; }
184 void setPrinting(bool printing) { m_printing = printing; }
185
186 bool isAccelerated() const { return m_accelerated; }
187 void setAccelerated(bool accelerated) { m_accelerated = accelerated; }
188
189 // The opaque region is empty until tracking is turned on.
190 // It is never clerared by the context.
191 void setTrackOpaqueRegion(bool track) { m_trackOpaqueRegion = track; }
192 const OpaqueRegionSkia& opaqueRegion() const { return m_opaqueRegion; }
193
194 // The text region is empty until tracking is turned on.
195 // It is never clerared by the context.
196 void setTrackTextRegion(bool track) { m_trackTextRegion = track; }
197 const SkRect& textRegion() const { return m_textRegion; }
198
199 bool updatingControlTints() const { return m_updatingControlTints; }
200 void setUpdatingControlTints(bool updatingTints) { m_updatingControlTints = updatingTints; }
201
202 AnnotationModeFlags annotationMode() const { return m_annotationMode; }
203 void setAnnotationMode(const AnnotationModeFlags mode) { m_annotationMode = mode; }
204
205 SkColorFilter* colorFilter();
206 void setColorFilter(ColorFilter);
207 // ---------- End state management methods -----------------
208
209 // Get the contents of the image buffer
210 bool readPixels(SkBitmap*, int, int, SkCanvas::Config8888 = SkCanvas::kNativ e_Premul_Config8888);
211
212 // Sets up the paint for the current fill style.
213 void setupPaintForFilling(SkPaint*) const;
214
215 // Sets up the paint for stroking. Returns a float representing the
216 // effective width of the pen. If a non-zero length is provided, the
217 // number of dashes/dots on a dashed/dotted line will be adjusted to
218 // start and end that length with a dash/dot.
219 float setupPaintForStroking(SkPaint*, int length = 0) const;
220
221 // These draw methods will do both stroking and filling.
222 // FIXME: ...except drawRect(), which fills properly but always strokes
223 // using a 1-pixel stroke inset from the rect borders (of the correct
224 // stroke color).
225 void drawRect(const IntRect&);
226 void drawLine(const IntPoint&, const IntPoint&);
227 void drawEllipse(const IntRect&);
228 void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntia lias = false);
229
230 void fillPath(const Path&);
231 void strokePath(const Path&);
232
233 void fillEllipse(const FloatRect&);
234 void strokeEllipse(const FloatRect&);
235
236 void fillRect(const FloatRect&);
237 void fillRect(const FloatRect&, const Color&);
238 void fillRect(const FloatRect&, const Color&, CompositeOperator);
239 void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&);
240 void fillRoundedRect(const RoundedRect&, const Color&);
241
242 void clearRect(const FloatRect&);
243
244 void strokeRect(const FloatRect&, float lineWidth);
245
246 void drawDisplayList(DisplayList*);
247
248 void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceO ver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
249 void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOv er, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQuali tyScale = false);
250 void drawImage(Image*, const IntPoint& destPoint, const IntRect& srcRect, Co mpositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespec tImageOrientation);
251 void drawImage(Image*, const FloatRect& destRect);
252 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotResp ectImageOrientation, bool useLowQualityScale = false);
253 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, blink::WebBlendMode, RespectImageOrientationEnum = DoNotRespe ctImageOrientation, bool useLowQualityScale = false);
254
255 void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoin t, const IntSize& tileSize,
256 CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false , blink::WebBlendMode = blink::WebBlendModeNormal, const IntSize& repeatSpacing = IntSize());
257 void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect,
258 const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::Stretch Tile, Image::TileRule vRule = Image::StretchTile,
259 CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false );
260
261 void drawImageBuffer(ImageBuffer*, const IntPoint&, CompositeOperator = Comp ositeSourceOver, blink::WebBlendMode = blink::WebBlendModeNormal);
262 void drawImageBuffer(ImageBuffer*, const IntRect&, CompositeOperator = Compo siteSourceOver, blink::WebBlendMode = blink::WebBlendModeNormal, bool useLowQual ityScale = false);
263 void drawImageBuffer(ImageBuffer*, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, blink::WebBlendMode = blink:: WebBlendModeNormal);
264 void drawImageBuffer(ImageBuffer*, const IntRect& destRect, const IntRect& s rcRect, CompositeOperator = CompositeSourceOver, blink::WebBlendMode = blink::We bBlendModeNormal, bool useLowQualityScale = false);
265 void drawImageBuffer(ImageBuffer*, const FloatRect& destRect);
266 void drawImageBuffer(ImageBuffer*, const FloatRect& destRect, const FloatRec t& srcRect, CompositeOperator = CompositeSourceOver, blink::WebBlendMode = blink ::WebBlendModeNormal, bool useLowQualityScale = false);
267
268 // These methods write to the canvas and modify the opaque region, if tracke d.
269 // Also drawLine(const IntPoint& point1, const IntPoint& point2) and fillRou ndedRect
270 void writePixels(const SkBitmap&, int x, int y, SkCanvas::Config8888 = SkCan vas::kNative_Premul_Config8888);
271 void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0);
272 void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkP aint* = 0);
273 void drawOval(const SkRect&, const SkPaint&);
274 void drawPath(const SkPath&, const SkPaint&);
275 // After drawing directly to the context's canvas, use this function to noti fy the context so
276 // it can track the opaque region.
277 // FIXME: this is still needed only because ImageSkia::paintSkBitmap() may n eed to notify for a
278 // smaller rect than the one drawn to, due to its clipping logic.
279 void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0);
280 void drawRect(const SkRect&, const SkPaint&);
281 void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], c onst SkRect& textRect, const SkPaint&);
282 void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[] , SkScalar constY, const SkRect& textRect, const SkPaint&);
283 void drawTextOnPath(const void* text, size_t byteLength, const SkPath&, cons t SkRect& textRect, const SkMatrix*, const SkPaint&);
284
285 void clip(const IntRect& rect) { clip(FloatRect(rect)); }
286 void clip(const FloatRect& rect) { clipRect(rect); }
287 void clipRoundedRect(const RoundedRect&);
288 void clipOut(const IntRect& rect) { clipRect(rect, NotAntiAliased, SkRegion: :kDifference_Op); }
289 void clipOutRoundedRect(const RoundedRect&);
290 void clipPath(const Path&, WindRule = RULE_EVENODD);
291 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
292 bool clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op);
293
294 void drawText(const Font&, const TextRunPaintInfo&, const FloatPoint&);
295 void drawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicStr ing& mark, const FloatPoint&);
296 void drawBidiText(const Font&, const TextRunPaintInfo&, const FloatPoint&, F ont::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady);
297 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in t h, const Color& backgroundColor, int from = 0, int to = -1);
298
299 void drawLineForText(const FloatPoint&, float width, bool printing);
300 enum DocumentMarkerLineStyle {
301 DocumentMarkerSpellingLineStyle,
302 DocumentMarkerGrammarLineStyle
303 };
304 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke rLineStyle);
305
306 void beginTransparencyLayer(float opacity, const FloatRect* = 0);
307 void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, Colo rFilter = ColorFilterNone);
308 void endLayer();
309
310 // Instead of being dispatched to the active canvas, draw commands following beginRecording()
311 // are stored in a display list that can be replayed at a later time.
312 void beginRecording(const FloatRect& bounds);
313 PassRefPtr<DisplayList> endRecording();
314
315 bool hasShadow() const;
316 void setShadow(const FloatSize& offset, float blur, const Color&,
317 DrawLooper::ShadowTransformMode = DrawLooper::ShadowRespectsTransforms,
318 DrawLooper::ShadowAlphaMode = DrawLooper::ShadowRespectsAlpha);
319 void clearShadow() { clearDrawLooper(); }
320
321 // It is assumed that this draw looper is used only for shadows
322 // (i.e. a draw looper is set if and only if there is a shadow).
323 void setDrawLooper(const DrawLooper&);
324 void clearDrawLooper();
325
326 void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Colo r&);
327 void drawFocusRing(const Path&, int width, int offset, const Color&);
328
329 enum Edge {
330 NoEdge = 0,
331 TopEdge = 1 << 1,
332 RightEdge = 1 << 2,
333 BottomEdge = 1 << 3,
334 LeftEdge = 1 << 4
335 };
336 typedef unsigned Edges;
337 void drawInnerShadow(const RoundedRect&, const Color& shadowColor, const Int Size shadowOffset, int shadowBlur, int shadowSpread, Edges clippedEdges = NoEdge );
338
339 // This clip function is used only by <canvas> code. It allows
340 // implementations to handle clipping on the canvas differently since
341 // the discipline is different.
342 void canvasClip(const Path&, WindRule = RULE_EVENODD);
343 void clipOut(const Path&);
344
345 // ---------- Transformation methods -----------------
346 enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDevic eScale };
347 AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDevi ceScale) const;
348 void concatCTM(const AffineTransform& affine) { concat(affineTransformToSkMa trix(affine)); }
349 void setCTM(const AffineTransform& affine) { setMatrix(affineTransformToSkMa trix(affine)); }
350 void setMatrix(const SkMatrix&);
351
352 void scale(const FloatSize&);
353 void rotate(float angleInRadians);
354 void translate(const FloatSize& size) { translate(size.width(), size.height( )); }
355 void translate(float x, float y);
356
357 // This function applies the device scale factor to the context, making the context capable of
358 // acting as a base-level context for a HiDPI environment.
359 void applyDeviceScaleFactor(float deviceScaleFactor) { scale(FloatSize(devic eScaleFactor, deviceScaleFactor)); }
360 // ---------- End transformation methods -----------------
361
362 // URL drawing
363 void setURLForRect(const KURL&, const IntRect&);
364 void setURLFragmentForRect(const String& name, const IntRect&);
365 void addURLTargetAtPoint(const String& name, const IntPoint&);
366 bool supportsURLFragments() { return printing(); }
367
368 // Create an image buffer compatible with this context, with suitable resolu tion
369 // for drawing into the buffer and then into this context.
370 PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, bool hasAlpha = true) const;
371
372 static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, floa t strokeWidth, StrokeStyle);
373
374 void beginAnnotation(const GraphicsContextAnnotation&);
375 void endAnnotation();
376
377 private:
378 static void addCornerArc(SkPath*, const SkRect&, const IntSize&, int);
379 static void setPathFromConvexPoints(SkPath*, size_t, const FloatPoint*);
380 static void setRadii(SkVector*, IntSize, IntSize, IntSize, IntSize);
381
382 static PassRefPtr<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFi lter);
383
384 #if OS(MACOSX)
385 static inline int getFocusRingOutset(int offset) { return offset + 2; }
386 #else
387 static inline int getFocusRingOutset(int offset) { return 0; }
388 static const SkPMColor lineColors(int);
389 static const SkPMColor antiColors1(int);
390 static const SkPMColor antiColors2(int);
391 static void draw1xMarker(SkBitmap*, int);
392 static void draw2xMarker(SkBitmap*, int);
393 #endif
394
395 // Return value % max, but account for value possibly being negative.
396 static int fastMod(int value, int max)
397 {
398 bool isNeg = false;
399 if (value < 0) {
400 value = -value;
401 isNeg = true;
402 }
403 if (value >= max)
404 value %= max;
405 if (isNeg)
406 value = -value;
407 return value;
408 }
409
410 // Sets up the common flags on a paint for antialiasing, effects, etc.
411 // This is implicitly called by setupPaintFill and setupPaintStroke, but
412 // you may wish to call it directly sometimes if you don't want that other
413 // behavior.
414 void setupPaintCommon(SkPaint*) const;
415
416 // Helpers for drawing a focus ring (drawFocusRing)
417 void drawOuterPath(const SkPath&, SkPaint&, int);
418 void drawInnerPath(const SkPath&, SkPaint&, int);
419
420 // SkCanvas wrappers.
421 bool isDrawingToLayer() const { return m_canvas->isDrawingToLayer(); }
422
423 bool clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op);
424 bool clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion:: Op = SkRegion::kIntersect_Op);
425
426 bool concat(const SkMatrix&);
427
428 // common code between setupPaintFor[Filling,Stroking]
429 void setupShader(SkPaint*, Gradient*, Pattern*, SkColor) const;
430
431 // Apply deferred saves
432 void realizeSave(SkCanvas::SaveFlags flags)
433 {
434 if (m_deferredSaveFlags & flags) {
435 m_canvas->save((SkCanvas::SaveFlags)m_deferredSaveFlags);
436 m_deferredSaveFlags = 0;
437 }
438 }
439
440 void didDrawTextInRect(const SkRect& textRect);
441
442 void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleR ect, const Color&);
443
444 bool isRecording() const;
445
446 // null indicates painting is disabled. Never delete this object.
447 SkCanvas* m_canvas;
448
449 // Pointer to the current drawing state. This is a cached value of m_stateSt ack.last().
450 GraphicsContextState* m_state;
451 // States stack. Enables local drawing state change with save()/restore() ca lls.
452 // Use OwnPtr to avoid copying the large state structure.
453 Vector<OwnPtr<GraphicsContextState> > m_stateStack;
454
455 // Currently pending save flags.
456 // FIXME: While defined as a bitmask of SkCanvas::SaveFlags, this is mostly used as a bool.
457 // It will come in handy when adding granular save() support (clip vs . matrix vs. paint).
458 // crbug.com/233713
459 struct DeferredSaveState;
460 unsigned m_deferredSaveFlags;
461 Vector<DeferredSaveState> m_saveStateStack;
462
463 AnnotationModeFlags m_annotationMode;
464
465 struct RecordingState;
466 Vector<RecordingState> m_recordingStateStack;
467
468 #if !ASSERT_DISABLED
469 unsigned m_annotationCount;
470 unsigned m_layerCount;
471 #endif
472 // Tracks the region painted opaque via the GraphicsContext.
473 OpaqueRegionSkia m_opaqueRegion;
474 bool m_trackOpaqueRegion : 1;
475
476 // Tracks the region where text is painted via the GraphicsContext.
477 bool m_trackTextRegion : 1;
478 SkRect m_textRegion;
479
480 // Are we on a high DPI display? If so, spelling and grammar markers are lar ger.
481 bool m_useHighResMarker : 1;
482 // FIXME: Make this go away: crbug.com/236892
483 bool m_updatingControlTints : 1;
484 bool m_accelerated : 1;
485 bool m_isCertainlyOpaque : 1;
486 bool m_printing : 1;
487 };
488
489 } // namespace WebCore
490
491 #endif // GraphicsContext_h
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/GradientGeneratedImage.cpp ('k') | Source/core/platform/graphics/GraphicsContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698