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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 enum AccessMode { | 68 enum AccessMode { |
69 ReadOnly, | 69 ReadOnly, |
70 ReadWrite | 70 ReadWrite |
71 }; | 71 }; |
72 | 72 |
73 enum DisabledMode { | 73 enum DisabledMode { |
74 NothingDisabled = 0, // Run as normal. | 74 NothingDisabled = 0, // Run as normal. |
75 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of th
e context from performance tests. | 75 FullyDisabled = 1 // Do absolutely minimal work to remove the cost of th
e context from performance tests. |
76 }; | 76 }; |
77 | 77 |
| 78 // A 0 canvas is allowed, but in such cases the context must only have canva
s |
| 79 // related commands called when within a beginRecording/endRecording block. |
| 80 // Furthermore, save/restore calls must be balanced any time the canvas is 0
. |
78 explicit GraphicsContext(SkCanvas*, DisabledMode = NothingDisabled); | 81 explicit GraphicsContext(SkCanvas*, DisabledMode = NothingDisabled); |
| 82 |
79 ~GraphicsContext(); | 83 ~GraphicsContext(); |
80 | 84 |
81 // Returns the canvas used for painting. Must not be called if painting is d
isabled. | 85 // 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, | 86 // 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. | 87 // so it should be avoided. Use the corresponding draw/matrix/clip methods i
nstead. |
84 SkCanvas* canvas() | 88 SkCanvas* canvas() |
85 { | 89 { |
86 // Flush any pending saves. | 90 // Flush any pending saves. |
87 realizeCanvasSave(); | 91 realizeCanvasSave(); |
88 | 92 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 477 } |
474 } | 478 } |
475 } | 479 } |
476 | 480 |
477 // Apply deferred canvas state saves | 481 // Apply deferred canvas state saves |
478 void realizeCanvasSave() | 482 void realizeCanvasSave() |
479 { | 483 { |
480 if (!m_pendingCanvasSave || contextDisabled()) | 484 if (!m_pendingCanvasSave || contextDisabled()) |
481 return; | 485 return; |
482 | 486 |
| 487 ASSERT(m_canvas); // m_pendingCanvasSave should never be true when no ca
nvas. |
483 m_canvas->save(); | 488 m_canvas->save(); |
484 m_pendingCanvasSave = false; | 489 m_pendingCanvasSave = false; |
485 } | 490 } |
486 | 491 |
487 void didDrawTextInRect(const SkRect& textRect); | 492 void didDrawTextInRect(const SkRect& textRect); |
488 | 493 |
489 void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleR
ect, const Color&); | 494 void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleR
ect, const Color&); |
490 | 495 |
491 bool isRecording() const; | 496 bool isRecording() const; |
492 | 497 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 bool m_accelerated : 1; | 541 bool m_accelerated : 1; |
537 bool m_isCertainlyOpaque : 1; | 542 bool m_isCertainlyOpaque : 1; |
538 bool m_printing : 1; | 543 bool m_printing : 1; |
539 bool m_antialiasHairlineImages : 1; | 544 bool m_antialiasHairlineImages : 1; |
540 bool m_shouldSmoothFonts : 1; | 545 bool m_shouldSmoothFonts : 1; |
541 }; | 546 }; |
542 | 547 |
543 } // namespace blink | 548 } // namespace blink |
544 | 549 |
545 #endif // GraphicsContext_h | 550 #endif // GraphicsContext_h |
OLD | NEW |