OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 RefPtr<DisplayList> m_displayList; | 109 RefPtr<DisplayList> m_displayList; |
110 const SkMatrix m_savedMatrix; | 110 const SkMatrix m_savedMatrix; |
111 }; | 111 }; |
112 | 112 |
113 GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
Painting) | 113 GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
Painting) |
114 : m_canvas(canvas) | 114 : m_canvas(canvas) |
115 , m_paintStateStack() | 115 , m_paintStateStack() |
116 , m_paintStateIndex(0) | 116 , m_paintStateIndex(0) |
117 , m_pendingCanvasSave(false) | 117 , m_pendingCanvasSave(false) |
118 , m_annotationMode(0) | 118 , m_annotationMode(0) |
119 #if !ASSERT_DISABLED | 119 #if ASSERT_ENABLED |
120 , m_annotationCount(0) | 120 , m_annotationCount(0) |
121 , m_layerCount(0) | 121 , m_layerCount(0) |
122 , m_disableDestructionChecks(false) | 122 , m_disableDestructionChecks(false) |
123 #endif | 123 #endif |
124 , m_disabledState(disableContextOrPainting) | 124 , m_disabledState(disableContextOrPainting) |
125 , m_trackOpaqueRegion(false) | 125 , m_trackOpaqueRegion(false) |
126 , m_trackTextRegion(false) | 126 , m_trackTextRegion(false) |
127 , m_useHighResMarker(false) | 127 , m_useHighResMarker(false) |
128 , m_updatingControlTints(false) | 128 , m_updatingControlTints(false) |
129 , m_accelerated(false) | 129 , m_accelerated(false) |
130 , m_isCertainlyOpaque(true) | 130 , m_isCertainlyOpaque(true) |
131 , m_printing(false) | 131 , m_printing(false) |
132 , m_antialiasHairlineImages(false) | 132 , m_antialiasHairlineImages(false) |
133 { | 133 { |
134 if (!canvas) | 134 if (!canvas) |
135 m_disabledState |= PaintingDisabled; | 135 m_disabledState |= PaintingDisabled; |
136 | 136 |
137 // FIXME: Do some tests to determine how many states are typically used, and
allocate | 137 // FIXME: Do some tests to determine how many states are typically used, and
allocate |
138 // several here. | 138 // several here. |
139 m_paintStateStack.append(GraphicsContextState::create()); | 139 m_paintStateStack.append(GraphicsContextState::create()); |
140 m_paintState = m_paintStateStack.last().get(); | 140 m_paintState = m_paintStateStack.last().get(); |
141 } | 141 } |
142 | 142 |
143 GraphicsContext::~GraphicsContext() | 143 GraphicsContext::~GraphicsContext() |
144 { | 144 { |
145 #if !ASSERT_DISABLED | 145 #if ASSERT_ENABLED |
146 if (!m_disableDestructionChecks) { | 146 if (!m_disableDestructionChecks) { |
147 ASSERT(!m_paintStateIndex); | 147 ASSERT(!m_paintStateIndex); |
148 ASSERT(!m_paintState->saveCount()); | 148 ASSERT(!m_paintState->saveCount()); |
149 ASSERT(!m_annotationCount); | 149 ASSERT(!m_annotationCount); |
150 ASSERT(!m_layerCount); | 150 ASSERT(!m_layerCount); |
151 ASSERT(m_recordingStateStack.isEmpty()); | 151 ASSERT(m_recordingStateStack.isEmpty()); |
152 ASSERT(m_canvasStateStack.isEmpty()); | 152 ASSERT(m_canvasStateStack.isEmpty()); |
153 } | 153 } |
154 #endif | 154 #endif |
155 } | 155 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 canvas()->beginCommentGroup("GraphicsContextAnnotation"); | 219 canvas()->beginCommentGroup("GraphicsContextAnnotation"); |
220 | 220 |
221 GraphicsContextAnnotation annotation(rendererName, paintPhase, elementId, el
ementClass, elementTag); | 221 GraphicsContextAnnotation annotation(rendererName, paintPhase, elementId, el
ementClass, elementTag); |
222 AnnotationList annotations; | 222 AnnotationList annotations; |
223 annotation.asAnnotationList(annotations); | 223 annotation.asAnnotationList(annotations); |
224 | 224 |
225 AnnotationList::const_iterator end = annotations.end(); | 225 AnnotationList::const_iterator end = annotations.end(); |
226 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i
t) | 226 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i
t) |
227 canvas()->addComment(it->first, it->second.ascii().data()); | 227 canvas()->addComment(it->first, it->second.ascii().data()); |
228 | 228 |
229 #if !ASSERT_DISABLED | 229 #if ASSERT_ENABLED |
230 ++m_annotationCount; | 230 ++m_annotationCount; |
231 #endif | 231 #endif |
232 } | 232 } |
233 | 233 |
234 void GraphicsContext::endAnnotation() | 234 void GraphicsContext::endAnnotation() |
235 { | 235 { |
236 if (contextDisabled()) | 236 if (contextDisabled()) |
237 return; | 237 return; |
238 | 238 |
239 canvas()->endCommentGroup(); | 239 canvas()->endCommentGroup(); |
240 | 240 |
241 ASSERT(m_annotationCount > 0); | 241 ASSERT(m_annotationCount > 0); |
242 #if !ASSERT_DISABLED | 242 #if ASSERT_ENABLED |
243 --m_annotationCount; | 243 --m_annotationCount; |
244 #endif | 244 #endif |
245 } | 245 } |
246 | 246 |
247 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) | 247 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) |
248 { | 248 { |
249 if (contextDisabled()) | 249 if (contextDisabled()) |
250 return; | 250 return; |
251 | 251 |
252 ASSERT(pattern); | 252 ASSERT(pattern); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g
et()); | 456 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g
et()); |
457 layerPaint.setImageFilter(imageFilter); | 457 layerPaint.setImageFilter(imageFilter); |
458 | 458 |
459 if (bounds) { | 459 if (bounds) { |
460 SkRect skBounds = WebCoreFloatRectToSKRect(*bounds); | 460 SkRect skBounds = WebCoreFloatRectToSKRect(*bounds); |
461 saveLayer(&skBounds, &layerPaint); | 461 saveLayer(&skBounds, &layerPaint); |
462 } else { | 462 } else { |
463 saveLayer(0, &layerPaint); | 463 saveLayer(0, &layerPaint); |
464 } | 464 } |
465 | 465 |
466 #if !ASSERT_DISABLED | 466 #if ASSERT_ENABLED |
467 ++m_layerCount; | 467 ++m_layerCount; |
468 #endif | 468 #endif |
469 } | 469 } |
470 | 470 |
471 void GraphicsContext::endLayer() | 471 void GraphicsContext::endLayer() |
472 { | 472 { |
473 if (contextDisabled()) | 473 if (contextDisabled()) |
474 return; | 474 return; |
475 | 475 |
476 restoreLayer(); | 476 restoreLayer(); |
477 | 477 |
478 ASSERT(m_layerCount > 0); | 478 ASSERT(m_layerCount > 0); |
479 #if !ASSERT_DISABLED | 479 #if ASSERT_ENABLED |
480 --m_layerCount; | 480 --m_layerCount; |
481 #endif | 481 #endif |
482 } | 482 } |
483 | 483 |
484 void GraphicsContext::beginRecording(const FloatRect& bounds) | 484 void GraphicsContext::beginRecording(const FloatRect& bounds) |
485 { | 485 { |
486 RefPtr<DisplayList> displayList = adoptRef(new DisplayList(bounds)); | 486 RefPtr<DisplayList> displayList = adoptRef(new DisplayList(bounds)); |
487 | 487 |
488 SkCanvas* savedCanvas = m_canvas; | 488 SkCanvas* savedCanvas = m_canvas; |
489 SkMatrix savedMatrix = getTotalMatrix(); | 489 SkMatrix savedMatrix = getTotalMatrix(); |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 | 1817 |
1818 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1818 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1819 { | 1819 { |
1820 if (m_trackTextRegion) { | 1820 if (m_trackTextRegion) { |
1821 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); | 1821 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); |
1822 m_textRegion.join(textRect); | 1822 m_textRegion.join(textRect); |
1823 } | 1823 } |
1824 } | 1824 } |
1825 | 1825 |
1826 } | 1826 } |
OLD | NEW |