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 12 matching lines...) Expand all Loading... |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef GraphicsContext_h | 28 #ifndef GraphicsContext_h |
29 #define GraphicsContext_h | 29 #define GraphicsContext_h |
30 | 30 |
31 #include "platform/PlatformExport.h" | 31 #include "platform/PlatformExport.h" |
32 #include "platform/fonts/Font.h" | 32 #include "platform/fonts/Font.h" |
| 33 #include "platform/graphics/ColorBehavior.h" |
33 #include "platform/graphics/DashArray.h" | 34 #include "platform/graphics/DashArray.h" |
34 #include "platform/graphics/DrawLooperBuilder.h" | 35 #include "platform/graphics/DrawLooperBuilder.h" |
35 #include "platform/graphics/GraphicsContextState.h" | 36 #include "platform/graphics/GraphicsContextState.h" |
36 #include "platform/graphics/ImageOrientation.h" | 37 #include "platform/graphics/ImageOrientation.h" |
37 #include "platform/graphics/skia/SkiaUtils.h" | 38 #include "platform/graphics/skia/SkiaUtils.h" |
38 #include "third_party/skia/include/core/SkClipOp.h" | 39 #include "third_party/skia/include/core/SkClipOp.h" |
39 #include "third_party/skia/include/core/SkMetaData.h" | 40 #include "third_party/skia/include/core/SkMetaData.h" |
40 #include "third_party/skia/include/core/SkPictureRecorder.h" | 41 #include "third_party/skia/include/core/SkPictureRecorder.h" |
41 #include "third_party/skia/include/core/SkRefCnt.h" | 42 #include "third_party/skia/include/core/SkRefCnt.h" |
42 #include "wtf/Allocator.h" | 43 #include "wtf/Allocator.h" |
(...skipping 20 matching lines...) Expand all Loading... |
63 WTF_MAKE_NONCOPYABLE(GraphicsContext); | 64 WTF_MAKE_NONCOPYABLE(GraphicsContext); |
64 USING_FAST_MALLOC(GraphicsContext); | 65 USING_FAST_MALLOC(GraphicsContext); |
65 | 66 |
66 public: | 67 public: |
67 enum DisabledMode { | 68 enum DisabledMode { |
68 NothingDisabled = 0, // Run as normal. | 69 NothingDisabled = 0, // Run as normal. |
69 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of | 70 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of |
70 // the context from performance tests. | 71 // the context from performance tests. |
71 }; | 72 }; |
72 | 73 |
73 explicit GraphicsContext(PaintController&, | 74 explicit GraphicsContext( |
74 DisabledMode = NothingDisabled, | 75 PaintController&, |
75 SkMetaData* = 0); | 76 DisabledMode = NothingDisabled, |
| 77 SkMetaData* = 0, |
| 78 ColorBehavior = ColorBehavior::transformToGlobalTarget()); |
76 | 79 |
77 ~GraphicsContext(); | 80 ~GraphicsContext(); |
78 | 81 |
79 SkCanvas* canvas() { return m_canvas; } | 82 SkCanvas* canvas() { return m_canvas; } |
80 const SkCanvas* canvas() const { return m_canvas; } | 83 const SkCanvas* canvas() const { return m_canvas; } |
81 | 84 |
82 PaintController& getPaintController() { return m_paintController; } | 85 PaintController& getPaintController() { return m_paintController; } |
| 86 const ColorBehavior& getColorBehavior() const { return m_colorBehavior; } |
83 | 87 |
84 bool contextDisabled() const { return m_disabledState; } | 88 bool contextDisabled() const { return m_disabledState; } |
85 | 89 |
86 // ---------- State management methods ----------------- | 90 // ---------- State management methods ----------------- |
87 void save(); | 91 void save(); |
88 void restore(); | 92 void restore(); |
89 | 93 |
90 #if ENABLE(ASSERT) | 94 #if ENABLE(ASSERT) |
91 unsigned saveCount() const; | 95 unsigned saveCount() const; |
92 #endif | 96 #endif |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 // Current index on the stack. May not be the last thing on the stack. | 443 // Current index on the stack. May not be the last thing on the stack. |
440 unsigned m_paintStateIndex; | 444 unsigned m_paintStateIndex; |
441 | 445 |
442 // Raw pointer to the current state. | 446 // Raw pointer to the current state. |
443 GraphicsContextState* m_paintState; | 447 GraphicsContextState* m_paintState; |
444 | 448 |
445 SkPictureRecorder m_pictureRecorder; | 449 SkPictureRecorder m_pictureRecorder; |
446 | 450 |
447 SkMetaData m_metaData; | 451 SkMetaData m_metaData; |
448 | 452 |
| 453 const ColorBehavior m_colorBehavior; |
| 454 |
449 #if DCHECK_IS_ON() | 455 #if DCHECK_IS_ON() |
450 int m_layerCount; | 456 int m_layerCount; |
451 bool m_disableDestructionChecks; | 457 bool m_disableDestructionChecks; |
452 bool m_inDrawingRecorder; | 458 bool m_inDrawingRecorder; |
453 #endif | 459 #endif |
454 | 460 |
455 const DisabledMode m_disabledState; | 461 const DisabledMode m_disabledState; |
456 | 462 |
457 float m_deviceScaleFactor; | 463 float m_deviceScaleFactor; |
458 | 464 |
459 unsigned m_printing : 1; | 465 unsigned m_printing : 1; |
460 unsigned m_hasMetaData : 1; | 466 unsigned m_hasMetaData : 1; |
461 }; | 467 }; |
462 | 468 |
463 } // namespace blink | 469 } // namespace blink |
464 | 470 |
465 #endif // GraphicsContext_h | 471 #endif // GraphicsContext_h |
OLD | NEW |