OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 91 |
92 // ---------- State management methods ----------------- | 92 // ---------- State management methods ----------------- |
93 void save(); | 93 void save(); |
94 void restore(); | 94 void restore(); |
95 | 95 |
96 #if ENABLE(ASSERT) | 96 #if ENABLE(ASSERT) |
97 unsigned saveCount() const; | 97 unsigned saveCount() const; |
98 void disableDestructionChecks() { m_disableDestructionChecks = true; } | 98 void disableDestructionChecks() { m_disableDestructionChecks = true; } |
99 #endif | 99 #endif |
100 | 100 |
101 void saveLayer(const SkRect* bounds, const SkPaint*); | |
102 void restoreLayer(); | |
103 | |
104 bool hasStroke() const { return strokeStyle() != NoStroke && strokeThickness () > 0; } | 101 bool hasStroke() const { return strokeStyle() != NoStroke && strokeThickness () > 0; } |
105 | 102 |
106 float strokeThickness() const { return immutableState()->strokeData().thickn ess(); } | 103 float strokeThickness() const { return immutableState()->strokeData().thickn ess(); } |
107 void setStrokeThickness(float thickness) { mutableState()->setStrokeThicknes s(thickness); } | 104 void setStrokeThickness(float thickness) { mutableState()->setStrokeThicknes s(thickness); } |
108 | 105 |
109 StrokeStyle strokeStyle() const { return immutableState()->strokeData().styl e(); } | 106 StrokeStyle strokeStyle() const { return immutableState()->strokeData().styl e(); } |
110 void setStrokeStyle(StrokeStyle style) { mutableState()->setStrokeStyle(styl e); } | 107 void setStrokeStyle(StrokeStyle style) { mutableState()->setStrokeStyle(styl e); } |
111 | 108 |
112 Color strokeColor() const { return immutableState()->strokeColor(); } | 109 Color strokeColor() const { return immutableState()->strokeColor(); } |
113 void setStrokeColor(const Color& color) { mutableState()->setStrokeColor(col or); } | 110 void setStrokeColor(const Color& color) { mutableState()->setStrokeColor(col or); } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in t h, const Color& backgroundColor, int from = 0, int to = -1); | 316 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in t h, const Color& backgroundColor, int from = 0, int to = -1); |
320 | 317 |
321 void drawLineForText(const FloatPoint&, float width, bool printing); | 318 void drawLineForText(const FloatPoint&, float width, bool printing); |
322 enum DocumentMarkerLineStyle { | 319 enum DocumentMarkerLineStyle { |
323 DocumentMarkerSpellingLineStyle, | 320 DocumentMarkerSpellingLineStyle, |
324 DocumentMarkerGrammarLineStyle | 321 DocumentMarkerGrammarLineStyle |
325 }; | 322 }; |
326 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke rLineStyle); | 323 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke rLineStyle); |
327 | 324 |
328 void beginTransparencyLayer(float opacity, const FloatRect* = 0); | 325 void beginTransparencyLayer(float opacity, const FloatRect* = 0); |
326 // Apply CompositeOperator when the layer is composited on the backdrop (i.e . endLayer()). | |
327 // Don't change the current CompositeOperator state. | |
329 void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, Colo rFilter = ColorFilterNone, ImageFilter* = 0); | 328 void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, Colo rFilter = ColorFilterNone, ImageFilter* = 0); |
330 void endLayer(); | 329 void endLayer(); |
331 | 330 |
332 void beginCull(const FloatRect&); | 331 void beginCull(const FloatRect&); |
333 void endCull(); | 332 void endCull(); |
334 | 333 |
335 // Instead of being dispatched to the active canvas, draw commands following beginRecording() | 334 // Instead of being dispatched to the active canvas, draw commands following beginRecording() |
336 // are stored in a display list that can be replayed at a later time. Pass i n the bounding | 335 // are stored in a display list that can be replayed at a later time. Pass i n the bounding |
337 // rectangle for the content in the list. | 336 // rectangle for the content in the list. |
338 void beginRecording(const FloatRect&, uint32_t = 0); | 337 void beginRecording(const FloatRect&, uint32_t = 0); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 #else | 428 #else |
430 static inline int focusRingOutset(int offset) { return 0; } | 429 static inline int focusRingOutset(int offset) { return 0; } |
431 static inline int focusRingWidth(int width) { return 1; } | 430 static inline int focusRingWidth(int width) { return 1; } |
432 static SkPMColor lineColors(int); | 431 static SkPMColor lineColors(int); |
433 static SkPMColor antiColors1(int); | 432 static SkPMColor antiColors1(int); |
434 static SkPMColor antiColors2(int); | 433 static SkPMColor antiColors2(int); |
435 static void draw1xMarker(SkBitmap*, int); | 434 static void draw1xMarker(SkBitmap*, int); |
436 static void draw2xMarker(SkBitmap*, int); | 435 static void draw2xMarker(SkBitmap*, int); |
437 #endif | 436 #endif |
438 | 437 |
438 void saveLayer(const SkRect* bounds, const SkPaint*); | |
439 void restoreLayer(); | |
dshwang
2014/10/16 15:58:20
go to private:
Justin Novosad
2014/10/16 17:51:58
Good idea
| |
440 | |
439 // Helpers for drawing a focus ring (drawFocusRing) | 441 // Helpers for drawing a focus ring (drawFocusRing) |
440 float prepareFocusRingPaint(SkPaint&, const Color&, int width) const; | 442 float prepareFocusRingPaint(SkPaint&, const Color&, int width) const; |
441 void drawFocusRingPath(const SkPath&, const Color&, int width); | 443 void drawFocusRingPath(const SkPath&, const Color&, int width); |
442 void drawFocusRingRect(const SkRect&, const Color&, int width); | 444 void drawFocusRingRect(const SkRect&, const Color&, int width); |
443 | 445 |
444 // SkCanvas wrappers. | 446 // SkCanvas wrappers. |
445 void clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op); | 447 void clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op); |
446 void clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion:: Op = SkRegion::kIntersect_Op); | 448 void clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion:: Op = SkRegion::kIntersect_Op); |
447 void concat(const SkMatrix&); | 449 void concat(const SkMatrix&); |
448 void drawRRect(const SkRRect&, const SkPaint&); | 450 void drawRRect(const SkRRect&, const SkPaint&); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 // Raw pointer to the current state. | 487 // Raw pointer to the current state. |
486 GraphicsContextState* m_paintState; | 488 GraphicsContextState* m_paintState; |
487 | 489 |
488 AnnotationModeFlags m_annotationMode; | 490 AnnotationModeFlags m_annotationMode; |
489 | 491 |
490 struct RecordingState; | 492 struct RecordingState; |
491 Vector<RecordingState> m_recordingStateStack; | 493 Vector<RecordingState> m_recordingStateStack; |
492 | 494 |
493 #if ENABLE(ASSERT) | 495 #if ENABLE(ASSERT) |
494 unsigned m_annotationCount; | 496 unsigned m_annotationCount; |
495 unsigned m_layerCount; | |
496 bool m_disableDestructionChecks; | 497 bool m_disableDestructionChecks; |
497 #endif | 498 #endif |
499 // Keep the top of the clip stack of each layer. It's needed because beginLa yer()/endLayer() has the different contract | |
500 // from SkCanvas::saveLayer()/restore(). When endLayer() calls SkCanvas::res tore(), the clip state is restored before beginLayer(). | |
501 // This member is used to re-apply all clip operations after beginLayer(). I mportant to note that SkCanvas::saveLayer() | |
502 // may perform an additional clip operation, which prevent endLayer() from g etting the stack pointer by itself. | |
503 Vector<unsigned> m_clipStackPointersOfLayerStack; | |
504 | |
498 // Tracks the region painted opaque via the GraphicsContext. | 505 // Tracks the region painted opaque via the GraphicsContext. |
499 RegionTracker m_trackedRegion; | 506 RegionTracker m_trackedRegion; |
500 | 507 |
501 // Tracks the region where text is painted via the GraphicsContext. | 508 // Tracks the region where text is painted via the GraphicsContext. |
502 SkRect m_textRegion; | 509 SkRect m_textRegion; |
503 | 510 |
504 unsigned m_disabledState; | 511 unsigned m_disabledState; |
505 | 512 |
506 float m_deviceScaleFactor; | 513 float m_deviceScaleFactor; |
507 | 514 |
508 // Activation for the above region tracking features | 515 // Activation for the above region tracking features |
509 unsigned m_regionTrackingMode : 2; | 516 unsigned m_regionTrackingMode : 2; |
510 bool m_trackTextRegion : 1; | 517 bool m_trackTextRegion : 1; |
511 | 518 |
512 bool m_accelerated : 1; | 519 bool m_accelerated : 1; |
513 bool m_isCertainlyOpaque : 1; | 520 bool m_isCertainlyOpaque : 1; |
514 bool m_printing : 1; | 521 bool m_printing : 1; |
515 bool m_antialiasHairlineImages : 1; | 522 bool m_antialiasHairlineImages : 1; |
516 bool m_shouldSmoothFonts : 1; | 523 bool m_shouldSmoothFonts : 1; |
517 }; | 524 }; |
518 | 525 |
519 } // namespace blink | 526 } // namespace blink |
520 | 527 |
521 #endif // GraphicsContext_h | 528 #endif // GraphicsContext_h |
OLD | NEW |