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

Side by Side Diff: sky/engine/platform/graphics/GraphicsContext.h.orig

Issue 849663002: Remove extraneous files (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/engine/platform/graphics/GraphicsContext.cpp.orig ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SKY_ENGINE_PLATFORM_GRAPHICS_GRAPHICSCONTEXT_H_
29 #define SKY_ENGINE_PLATFORM_GRAPHICS_GRAPHICSCONTEXT_H_
30
31 #include "sky/engine/platform/PlatformExport.h"
32 #include "sky/engine/platform/fonts/Font.h"
33 #include "sky/engine/platform/geometry/FloatRect.h"
34 #include "sky/engine/platform/graphics/DashArray.h"
35 #include "sky/engine/platform/graphics/DrawLooperBuilder.h"
36 #include "sky/engine/platform/graphics/GraphicsContextAnnotation.h"
37 #include "sky/engine/platform/graphics/GraphicsContextState.h"
38 #include "sky/engine/platform/graphics/ImageBufferSurface.h"
39 #include "sky/engine/platform/graphics/ImageFilter.h"
40 #include "sky/engine/platform/graphics/ImageOrientation.h"
41 #include "sky/engine/platform/graphics/RegionTracker.h"
42 #include "sky/engine/platform/graphics/skia/SkiaUtils.h"
43 #include "sky/engine/wtf/FastAllocBase.h"
44 #include "sky/engine/wtf/Forward.h"
45 #include "sky/engine/wtf/Noncopyable.h"
46 #include "sky/engine/wtf/PassOwnPtr.h"
47
48 class SkBitmap;
49 class SkPaint;
50 class SkPath;
51 class SkRRect;
52 class SkTextBlob;
53 struct SkRect;
54
55 namespace blink {
56
57 class DisplayList;
58 class ImageBuffer;
59 class KURL;
60
61 class PLATFORM_EXPORT 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 enum DisabledMode {
74 NothingDisabled = 0, // Run as normal.
75 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of th e context from performance tests.
76 };
77
78 explicit GraphicsContext(SkCanvas*, DisabledMode = NothingDisabled);
79 ~GraphicsContext();
80
81 // Returns the canvas used for painting. Must not be called if painting is d isabled.
82 // Accessing the backing canvas this way flushes all queued save ops,
83 // so it should be avoided. Use the corresponding draw/matrix/clip methods i nstead.
84 SkCanvas* canvas()
85 {
86 // Flush any pending saves.
87 realizeCanvasSave();
88
89 return m_canvas;
90 }
91 const SkCanvas* canvas() const
92 {
93 return m_canvas;
94 }
95
96 void resetCanvas(SkCanvas*);
97
98 bool contextDisabled() const { return m_disabledState; }
99
100 // ---------- State management methods -----------------
101 void save();
102 void restore();
103 unsigned saveCount() { return m_canvasStateStack.size(); }
104 #if ENABLE(ASSERT)
105 void disableDestructionChecks() { m_disableDestructionChecks = true; }
106 #endif
107
108 void saveLayer(const SkRect* bounds, const SkPaint*);
109 void restoreLayer();
110
111 bool hasStroke() const { return strokeStyle() != NoStroke && strokeThickness () > 0; }
112
113 float strokeThickness() const { return immutableState()->strokeData().thickn ess(); }
114 void setStrokeThickness(float thickness) { mutableState()->setStrokeThicknes s(thickness); }
115
116 StrokeStyle strokeStyle() const { return immutableState()->strokeData().styl e(); }
117 void setStrokeStyle(StrokeStyle style) { mutableState()->setStrokeStyle(styl e); }
118
119 Color strokeColor() const { return immutableState()->strokeData().color(); }
120 void setStrokeColor(const Color& color) { mutableState()->setStrokeColor(col or); }
121 SkColor effectiveStrokeColor() const { return immutableState()->effectiveStr okeColor(); }
122
123 Pattern* strokePattern() const { return immutableState()->strokeData().patte rn(); }
124 void setStrokePattern(PassRefPtr<Pattern>);
125
126 Gradient* strokeGradient() const { return immutableState()->strokeData().gra dient(); }
127 void setStrokeGradient(PassRefPtr<Gradient>);
128
129 void setLineCap(LineCap cap) { mutableState()->setLineCap(cap); }
130 void setLineDash(const DashArray& dashes, float dashOffset) { mutableState() ->setLineDash(dashes, dashOffset); }
131 void setLineJoin(LineJoin join) { mutableState()->setLineJoin(join); }
132 void setMiterLimit(float limit) { mutableState()->setMiterLimit(limit); }
133
134 WindRule fillRule() const { return immutableState()->fillRule(); }
135 void setFillRule(WindRule fillRule) { mutableState()->setFillRule(fillRule); }
136
137 Color fillColor() const { return immutableState()->fillColor(); }
138 void setFillColor(const Color& color) { mutableState()->setFillColor(color); }
139 SkColor effectiveFillColor() const { return immutableState()->effectiveFillC olor(); }
140
141 void setFillPattern(PassRefPtr<Pattern>);
142 Pattern* fillPattern() const { return immutableState()->fillPattern(); }
143
144 void setFillGradient(PassRefPtr<Gradient>);
145 Gradient* fillGradient() const { return immutableState()->fillGradient(); }
146
147 SkDrawLooper* drawLooper() const { return immutableState()->drawLooper(); }
148
149 bool getTransformedClipBounds(FloatRect* bounds) const;
150 SkMatrix getTotalMatrix() const;
151
152 void setShouldAntialias(bool antialias) { mutableState()->setShouldAntialias (antialias); }
153 bool shouldAntialias() const { return immutableState()->shouldAntialias(); }
154
155 // Disable the anti-aliasing optimization for scales/multiple-of-90-degrees
156 // rotations of thin ("hairline") images.
157 // Note: This will only be reliable when the device pixel scale/ratio is
158 // fixed (e.g. when drawing to context backed by an ImageBuffer).
159 void disableAntialiasingOptimizationForHairlineImages() { ASSERT(!isRecordin g()); m_antialiasHairlineImages = true; }
160 bool shouldAntialiasHairlineImages() const { return m_antialiasHairlineImage s; }
161
162 void setShouldClampToSourceRect(bool clampToSourceRect) { mutableState()->se tShouldClampToSourceRect(clampToSourceRect); }
163 bool shouldClampToSourceRect() const { return immutableState()->shouldClampT oSourceRect(); }
164
165 // FIXME: the setter is only used once, at construction time; convert to a c onstructor param,
166 // and possibly consolidate with other flags (paintDisabled, isPrinting, ... )
167 void setShouldSmoothFonts(bool smoothFonts) { m_shouldSmoothFonts = smoothFo nts; }
168 bool shouldSmoothFonts() const { return m_shouldSmoothFonts; }
169
170 // Turn off LCD text for the paint if not supported on this context.
171 void adjustTextRenderMode(SkPaint*);
172 bool couldUseLCDRenderedText();
173
174 void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setText DrawingMode(mode); }
175 TextDrawingModeFlags textDrawingMode() const { return immutableState()->text DrawingMode(); }
176
177 void setAlphaAsFloat(float alpha) { mutableState()->setAlphaAsFloat(alpha);}
178 int getNormalizedAlpha() const
179 {
180 int alpha = immutableState()->alpha();
181 return alpha > 255 ? 255 : alpha;
182 }
183
184 void setImageInterpolationQuality(InterpolationQuality quality) { mutableSta te()->setInterpolationQuality(quality); }
185 InterpolationQuality imageInterpolationQuality() const { return immutableSta te()->interpolationQuality(); }
186
187 void setCompositeOperation(CompositeOperator, WebBlendMode = WebBlendModeNor mal);
188 CompositeOperator compositeOperation() const { return immutableState()->comp ositeOperator(); }
189 WebBlendMode blendModeOperation() const { return immutableState()->blendMode (); }
190
191 // Speicy the device scale factor which may change the way document markers
192 // and fonts are rendered.
193 void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; }
194 float deviceScaleFactor() const { return m_deviceScaleFactor; }
195
196 // If true we are (most likely) rendering to a web page and the
197 // canvas has been prepared with an opaque background. If false,
198 // the canvas may have transparency (as is the case when rendering
199 // to a canvas object).
200 void setCertainlyOpaque(bool isOpaque) { m_isCertainlyOpaque = isOpaque; }
201 bool isCertainlyOpaque() const { return m_isCertainlyOpaque; }
202
203 bool isAccelerated() const { return m_accelerated; }
204 void setAccelerated(bool accelerated) { m_accelerated = accelerated; }
205
206 // The opaque region is empty until tracking is turned on.
207 // It is never clerared by the context.
208 enum RegionTrackingMode {
209 RegionTrackingDisabled = 0,
210 RegionTrackingOpaque,
211 RegionTrackingOverwrite
212 };
213 void setRegionTrackingMode(RegionTrackingMode);
214 bool regionTrackingEnabled() { return m_regionTrackingMode != RegionTracking Disabled; }
215 const RegionTracker& opaqueRegion() const { return m_trackedRegion; }
216
217 // The text region is empty until tracking is turned on.
218 // It is never clerared by the context.
219 void setTrackTextRegion(bool track) { m_trackTextRegion = track; }
220 const SkRect& textRegion() const { return m_textRegion; }
221
222 AnnotationModeFlags annotationMode() const { return m_annotationMode; }
223 void setAnnotationMode(const AnnotationModeFlags mode) { m_annotationMode = mode; }
224
225 SkColorFilter* colorFilter() const;
226 void setColorFilter(ColorFilter);
227 // ---------- End state management methods -----------------
228
229 // Get the contents of the image buffer
230 bool readPixels(const SkImageInfo&, void* pixels, size_t rowBytes, int x, in t y);
231
232 // Get the current fill style.
233 const SkPaint& fillPaint() const { return immutableState()->fillPaint(); }
234
235 // Get the current stroke style.
236 const SkPaint& strokePaint() const { return immutableState()->strokePaint(); }
237
238 // These draw methods will do both stroking and filling.
239 // FIXME: ...except drawRect(), which fills properly but always strokes
240 // using a 1-pixel stroke inset from the rect borders (of the correct
241 // stroke color).
242 void drawRect(const IntRect&);
243 void drawLine(const IntPoint&, const IntPoint&);
244 void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntia lias = false);
245
246 void fillPath(const Path&);
247 void strokePath(const Path&);
248
249 void fillEllipse(const FloatRect&);
250 void strokeEllipse(const FloatRect&);
251
252 void fillRect(const FloatRect&);
253 void fillRect(const FloatRect&, const Color&);
254 void fillRect(const FloatRect&, const Color&, CompositeOperator);
255 void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&);
256 void fillRoundedRect(const RoundedRect&, const Color&);
257
258 void clearRect(const FloatRect&);
259
260 void strokeRect(const FloatRect&);
261 void strokeRect(const FloatRect&, float lineWidth);
262
263 void fillBetweenRoundedRects(const IntRect&, const IntSize& outerTopLeft, co nst IntSize& outerTopRight, const IntSize& outerBottomLeft, const IntSize& outer BottomRight,
264 const IntRect&, const IntSize& innerTopLeft, const IntSize& innerTopRigh t, const IntSize& innerBottomLeft, const IntSize& innerBottomRight, const Color& );
265 void fillBetweenRoundedRects(const RoundedRect&, const RoundedRect&, const C olor&);
266
267 void drawDisplayList(DisplayList*);
268
269 void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceO ver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
270 void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOv er, RespectImageOrientationEnum = DoNotRespectImageOrientation);
271 void drawImage(Image*, const FloatRect& destRect);
272 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotResp ectImageOrientation);
273 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, WebBlendMode, RespectImageOrientationEnum = DoNotRespectImage Orientation);
274
275 void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoin t, const IntSize& tileSize,
276 CompositeOperator = CompositeSourceOver, WebBlendMode = WebBlendModeNorm al, const IntSize& repeatSpacing = IntSize());
277 void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect,
278 const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::Stretch Tile, Image::TileRule vRule = Image::StretchTile,
279 CompositeOperator = CompositeSourceOver);
280
281 void drawImageBuffer(ImageBuffer*, const FloatRect& destRect, const FloatRec t* srcRect = 0, CompositeOperator = CompositeSourceOver, WebBlendMode = WebBlend ModeNormal);
282
283 void drawPicture(PassRefPtr<SkPicture>, const FloatRect& dest, const FloatRe ct& src, CompositeOperator, WebBlendMode);
284
285 // These methods write to the canvas and modify the opaque region, if tracke d.
286 // Also drawLine(const IntPoint& point1, const IntPoint& point2) and fillRou ndedRect
287 void writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in t x, int y);
288 void writePixels(const SkBitmap&, int x, int y);
289 void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0);
290 void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkP aint* = 0);
291 void drawOval(const SkRect&, const SkPaint&);
292 void drawPath(const SkPath&, const SkPaint&);
293 // After drawing directly to the context's canvas, use this function to noti fy the context so
294 // it can track the opaque region.
295 // FIXME: this is still needed only because ImageSkia::paintSkBitmap() may n eed to notify for a
296 // smaller rect than the one drawn to, due to its clipping logic.
297 void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0);
298 void drawRect(const SkRect&, const SkPaint&);
299 void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], c onst SkRect& textRect, const SkPaint&);
300 void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[] , SkScalar constY, const SkRect& textRect, const SkPaint&);
301 void drawTextBlob(const SkTextBlob*, const SkPoint& origin, const SkPaint&);
302
303 void clip(const IntRect& rect) { clipRect(rect); }
304 void clip(const FloatRect& rect) { clipRect(rect); }
305 void clipRoundedRect(const RoundedRect&, SkRegion::Op = SkRegion::kIntersect _Op);
306 void clipOut(const IntRect& rect) { clipRect(rect, NotAntiAliased, SkRegion: :kDifference_Op); }
307 void clipOutRoundedRect(const RoundedRect&);
308 void clipPath(const Path&, WindRule = RULE_EVENODD);
309 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
310 void clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op);
311
312 void drawText(const Font&, const TextRunPaintInfo&, const FloatPoint&);
313 void drawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicStr ing& mark, const FloatPoint&);
314 void drawBidiText(const Font&, const TextRunPaintInfo&, const FloatPoint&, F ont::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady);
315 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in t h, const Color& backgroundColor, int from = 0, int to = -1);
316
317 void drawLineForText(const FloatPoint&, float width);
318 enum DocumentMarkerLineStyle {
319 DocumentMarkerSpellingLineStyle,
320 DocumentMarkerGrammarLineStyle
321 };
322 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke rLineStyle);
323
324 void beginTransparencyLayer(float opacity, const FloatRect* = 0);
325 void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, Colo rFilter = ColorFilterNone, ImageFilter* = 0);
326 void endLayer();
327
328 // Instead of being dispatched to the active canvas, draw commands following beginRecording()
329 // are stored in a display list that can be replayed at a later time.
330 void beginRecording(const FloatRect& bounds);
331 PassRefPtr<DisplayList> endRecording();
332
333 bool hasShadow() const;
334 void setShadow(const FloatSize& offset, float blur, const Color&,
335 DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec tsTransforms,
336 DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl pha);
337 void clearShadow() { clearDrawLooper(); }
338
339 // It is assumed that this draw looper is used only for shadows
340 // (i.e. a draw looper is set if and only if there is a shadow).
341 // The builder passed into this method will be destroyed.
342 void setDrawLooper(PassOwnPtr<DrawLooperBuilder>);
343 void clearDrawLooper();
344
345 void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Colo r&);
346 void drawFocusRing(const Path&, int width, int offset, const Color&);
347
348 enum Edge {
349 NoEdge = 0,
350 TopEdge = 1 << 1,
351 RightEdge = 1 << 2,
352 BottomEdge = 1 << 3,
353 LeftEdge = 1 << 4
354 };
355 typedef unsigned Edges;
356 void drawInnerShadow(const RoundedRect&, const Color& shadowColor, const Int Size shadowOffset, int shadowBlur, int shadowSpread, Edges clippedEdges = NoEdge );
357
358 // This clip function is used only by <canvas> code. It allows
359 // implementations to handle clipping on the canvas differently since
360 // the discipline is different.
361 void canvasClip(const Path&, WindRule = RULE_EVENODD);
362 void clipOut(const Path&);
363
364 // ---------- Transformation methods -----------------
365 // Note that the getCTM method returns only the current transform from Blink 's perspective,
366 // which is not the final transform used to place content on screen. It cann ot be relied upon
367 // for testing where a point will appear on screen or how large it will be.
368 AffineTransform getCTM() const;
369 void concatCTM(const AffineTransform& affine) { concat(affineTransformToSkMa trix(affine)); }
370 void setCTM(const AffineTransform& affine) { setMatrix(affineTransformToSkMa trix(affine)); }
371 void setMatrix(const SkMatrix&);
372
373 void scale(float x, float y);
374 void rotate(float angleInRadians);
375 void translate(float x, float y);
376
377 // This function applies the device scale factor to the context, making the context capable of
378 // acting as a base-level context for a HiDPI environment.
379 void applyDeviceScaleFactor(float deviceScaleFactor) { scale(deviceScaleFact or, deviceScaleFactor); }
380 // ---------- End transformation methods -----------------
381
382 // URL drawing
383 void setURLForRect(const KURL&, const IntRect&);
384 void setURLFragmentForRect(const String& name, const IntRect&);
385 void addURLTargetAtPoint(const String& name, const IntPoint&);
386
387 // Create an image buffer compatible with this context, with suitable resolu tion
388 // for drawing into the buffer and then into this context.
389 PassOwnPtr<ImageBuffer> createRasterBuffer(const IntSize&, OpacityMode = Non Opaque) const;
390
391 static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, floa t strokeWidth, StrokeStyle);
392
393 void beginAnnotation(const AnnotationList&);
394 void endAnnotation();
395
396 void preparePaintForDrawRectToRect(
397 SkPaint*,
398 const SkRect& srcRect,
399 const SkRect& destRect,
400 CompositeOperator,
401 WebBlendMode,
402 bool isLazyDecoded = false,
403 bool isDataComplete = true) const;
404
405 static int focusRingOutsetExtent(int offset, int width)
406 {
407 return focusRingOutset(offset) + (focusRingWidth(width) + 1) / 2;
408 }
409
410 private:
411 const GraphicsContextState* immutableState() const { return m_paintState; }
412
413 GraphicsContextState* mutableState()
414 {
415 realizePaintSave();
416 return m_paintState;
417 }
418
419 static void setPathFromConvexPoints(SkPath*, size_t, const FloatPoint*);
420 static void setRadii(SkVector*, IntSize, IntSize, IntSize, IntSize);
421
422 static PassRefPtr<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFi lter);
423
424 static inline int focusRingOutset(int offset) { return 0; }
425 static inline int focusRingWidth(int width) { return 1; }
426 static SkPMColor lineColors(int);
427 static SkPMColor antiColors1(int);
428 static SkPMColor antiColors2(int);
429 static void draw1xMarker(SkBitmap*, int);
430 static void draw2xMarker(SkBitmap*, int);
431
432 // Helpers for drawing a focus ring (drawFocusRing)
433 float prepareFocusRingPaint(SkPaint&, const Color&, int width) const;
434 void drawFocusRingPath(const SkPath&, const Color&, int width);
435 void drawFocusRingRect(const SkRect&, const Color&, int width);
436
437
438 // SkCanvas wrappers.
439 void clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op);
440 void clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion:: Op = SkRegion::kIntersect_Op);
441 void concat(const SkMatrix&);
442 void drawRRect(const SkRRect&, const SkPaint&);
443
444 // Apply deferred paint state saves
445 void realizePaintSave()
446 {
447 if (contextDisabled())
448 return;
449
450 if (m_paintState->saveCount()) {
451 m_paintState->decrementSaveCount();
452 ++m_paintStateIndex;
453 if (m_paintStateStack.size() == m_paintStateIndex) {
454 m_paintStateStack.append(GraphicsContextState::createAndCopy(*m_ paintState));
455 m_paintState = m_paintStateStack[m_paintStateIndex].get();
456 } else {
457 GraphicsContextState* priorPaintState = m_paintState;
458 m_paintState = m_paintStateStack[m_paintStateIndex].get();
459 m_paintState->copy(*priorPaintState);
460 }
461 }
462 }
463
464 // Apply deferred canvas state saves
465 void realizeCanvasSave()
466 {
467 if (!m_pendingCanvasSave || contextDisabled())
468 return;
469
470 m_canvas->save();
471 m_pendingCanvasSave = false;
472 }
473
474 void didDrawTextInRect(const SkRect& textRect);
475
476 void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleR ect, const Color&);
477
478 bool isRecording() const;
479
480 // null indicates painting is contextDisabled. Never delete this object.
481 SkCanvas* m_canvas;
482
483 // Paint states stack. Enables local drawing state change with save()/restor e() calls.
484 // This state controls the appearance of drawn content.
485 // We do not delete from this stack to avoid memory churn.
486 Vector<OwnPtr<GraphicsContextState> > m_paintStateStack;
487 // Current index on the stack. May not be the last thing on the stack.
488 unsigned m_paintStateIndex;
489 // Raw pointer to the current state.
490 GraphicsContextState* m_paintState;
491
492 // Currently pending save flags for Skia Canvas state.
493 // Canvas state includes the canavs, it's matrix and clips. Think of it as _ where_
494 // the draw operations will happen.
495 struct CanvasSaveState;
496 Vector<CanvasSaveState> m_canvasStateStack;
497 bool m_pendingCanvasSave;
498
499 AnnotationModeFlags m_annotationMode;
500
501 struct RecordingState;
502 Vector<RecordingState> m_recordingStateStack;
503
504 #if ENABLE(ASSERT)
505 unsigned m_annotationCount;
506 unsigned m_layerCount;
507 bool m_disableDestructionChecks;
508 #endif
509 // Tracks the region painted opaque via the GraphicsContext.
510 RegionTracker m_trackedRegion;
511
512 // Tracks the region where text is painted via the GraphicsContext.
513 SkRect m_textRegion;
514
515 unsigned m_disabledState;
516
517 float m_deviceScaleFactor;
518
519 // Activation for the above region tracking features
520 unsigned m_regionTrackingMode : 2;
521 bool m_trackTextRegion : 1;
522
523 bool m_accelerated : 1;
524 bool m_isCertainlyOpaque : 1;
525 bool m_antialiasHairlineImages : 1;
526 bool m_shouldSmoothFonts : 1;
527 };
528
529 } // namespace blink
530
531 #endif // SKY_ENGINE_PLATFORM_GRAPHICS_GRAPHICSCONTEXT_H_
OLDNEW
« no previous file with comments | « sky/engine/platform/graphics/GraphicsContext.cpp.orig ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698