| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 RefPtr<DisplayList> m_displayList; | 110 RefPtr<DisplayList> m_displayList; |
| 111 const SkMatrix m_savedMatrix; | 111 const SkMatrix m_savedMatrix; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
Painting) | 114 GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
Painting) |
| 115 : m_canvas(canvas) | 115 : m_canvas(canvas) |
| 116 , m_paintStateStack() | 116 , m_paintStateStack() |
| 117 , m_paintStateIndex(0) | 117 , m_paintStateIndex(0) |
| 118 , m_pendingCanvasSave(false) | 118 , m_pendingCanvasSave(false) |
| 119 , m_annotationMode(0) | 119 , m_annotationMode(0) |
| 120 #if ASSERT_ENABLED | 120 #if ENABLE(ASSERT) |
| 121 , m_annotationCount(0) | 121 , m_annotationCount(0) |
| 122 , m_layerCount(0) | 122 , m_layerCount(0) |
| 123 , m_disableDestructionChecks(false) | 123 , m_disableDestructionChecks(false) |
| 124 #endif | 124 #endif |
| 125 , m_disabledState(disableContextOrPainting) | 125 , m_disabledState(disableContextOrPainting) |
| 126 , m_trackOpaqueRegion(false) | 126 , m_trackOpaqueRegion(false) |
| 127 , m_trackTextRegion(false) | 127 , m_trackTextRegion(false) |
| 128 , m_useHighResMarker(false) | 128 , m_useHighResMarker(false) |
| 129 , m_updatingControlTints(false) | 129 , m_updatingControlTints(false) |
| 130 , m_accelerated(false) | 130 , m_accelerated(false) |
| 131 , m_isCertainlyOpaque(true) | 131 , m_isCertainlyOpaque(true) |
| 132 , m_printing(false) | 132 , m_printing(false) |
| 133 , m_antialiasHairlineImages(false) | 133 , m_antialiasHairlineImages(false) |
| 134 { | 134 { |
| 135 if (!canvas) | 135 if (!canvas) |
| 136 m_disabledState |= PaintingDisabled; | 136 m_disabledState |= PaintingDisabled; |
| 137 | 137 |
| 138 // FIXME: Do some tests to determine how many states are typically used, and
allocate | 138 // FIXME: Do some tests to determine how many states are typically used, and
allocate |
| 139 // several here. | 139 // several here. |
| 140 m_paintStateStack.append(GraphicsContextState::create()); | 140 m_paintStateStack.append(GraphicsContextState::create()); |
| 141 m_paintState = m_paintStateStack.last().get(); | 141 m_paintState = m_paintStateStack.last().get(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 GraphicsContext::~GraphicsContext() | 144 GraphicsContext::~GraphicsContext() |
| 145 { | 145 { |
| 146 #if ASSERT_ENABLED | 146 #if ENABLE(ASSERT) |
| 147 if (!m_disableDestructionChecks) { | 147 if (!m_disableDestructionChecks) { |
| 148 ASSERT(!m_paintStateIndex); | 148 ASSERT(!m_paintStateIndex); |
| 149 ASSERT(!m_paintState->saveCount()); | 149 ASSERT(!m_paintState->saveCount()); |
| 150 ASSERT(!m_annotationCount); | 150 ASSERT(!m_annotationCount); |
| 151 ASSERT(!m_layerCount); | 151 ASSERT(!m_layerCount); |
| 152 ASSERT(m_recordingStateStack.isEmpty()); | 152 ASSERT(m_recordingStateStack.isEmpty()); |
| 153 ASSERT(m_canvasStateStack.isEmpty()); | 153 ASSERT(m_canvasStateStack.isEmpty()); |
| 154 } | 154 } |
| 155 #endif | 155 #endif |
| 156 } | 156 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 { | 215 { |
| 216 if (contextDisabled()) | 216 if (contextDisabled()) |
| 217 return; | 217 return; |
| 218 | 218 |
| 219 canvas()->beginCommentGroup("GraphicsContextAnnotation"); | 219 canvas()->beginCommentGroup("GraphicsContextAnnotation"); |
| 220 | 220 |
| 221 AnnotationList::const_iterator end = annotations.end(); | 221 AnnotationList::const_iterator end = annotations.end(); |
| 222 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i
t) | 222 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i
t) |
| 223 canvas()->addComment(it->first, it->second.ascii().data()); | 223 canvas()->addComment(it->first, it->second.ascii().data()); |
| 224 | 224 |
| 225 #if ASSERT_ENABLED | 225 #if ENABLE(ASSERT) |
| 226 ++m_annotationCount; | 226 ++m_annotationCount; |
| 227 #endif | 227 #endif |
| 228 } | 228 } |
| 229 | 229 |
| 230 void GraphicsContext::endAnnotation() | 230 void GraphicsContext::endAnnotation() |
| 231 { | 231 { |
| 232 if (contextDisabled()) | 232 if (contextDisabled()) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 ASSERT(m_annotationCount > 0); | 235 ASSERT(m_annotationCount > 0); |
| 236 canvas()->endCommentGroup(); | 236 canvas()->endCommentGroup(); |
| 237 | 237 |
| 238 #if ASSERT_ENABLED | 238 #if ENABLE(ASSERT) |
| 239 --m_annotationCount; | 239 --m_annotationCount; |
| 240 #endif | 240 #endif |
| 241 } | 241 } |
| 242 | 242 |
| 243 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) | 243 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) |
| 244 { | 244 { |
| 245 if (contextDisabled()) | 245 if (contextDisabled()) |
| 246 return; | 246 return; |
| 247 | 247 |
| 248 ASSERT(pattern); | 248 ASSERT(pattern); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g
et()); | 452 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g
et()); |
| 453 layerPaint.setImageFilter(imageFilter); | 453 layerPaint.setImageFilter(imageFilter); |
| 454 | 454 |
| 455 if (bounds) { | 455 if (bounds) { |
| 456 SkRect skBounds = WebCoreFloatRectToSKRect(*bounds); | 456 SkRect skBounds = WebCoreFloatRectToSKRect(*bounds); |
| 457 saveLayer(&skBounds, &layerPaint); | 457 saveLayer(&skBounds, &layerPaint); |
| 458 } else { | 458 } else { |
| 459 saveLayer(0, &layerPaint); | 459 saveLayer(0, &layerPaint); |
| 460 } | 460 } |
| 461 | 461 |
| 462 #if ASSERT_ENABLED | 462 #if ENABLE(ASSERT) |
| 463 ++m_layerCount; | 463 ++m_layerCount; |
| 464 #endif | 464 #endif |
| 465 } | 465 } |
| 466 | 466 |
| 467 void GraphicsContext::endLayer() | 467 void GraphicsContext::endLayer() |
| 468 { | 468 { |
| 469 if (contextDisabled()) | 469 if (contextDisabled()) |
| 470 return; | 470 return; |
| 471 | 471 |
| 472 restoreLayer(); | 472 restoreLayer(); |
| 473 | 473 |
| 474 ASSERT(m_layerCount > 0); | 474 ASSERT(m_layerCount > 0); |
| 475 #if ASSERT_ENABLED | 475 #if ENABLE(ASSERT) |
| 476 --m_layerCount; | 476 --m_layerCount; |
| 477 #endif | 477 #endif |
| 478 } | 478 } |
| 479 | 479 |
| 480 void GraphicsContext::beginRecording(const FloatRect& bounds) | 480 void GraphicsContext::beginRecording(const FloatRect& bounds) |
| 481 { | 481 { |
| 482 RefPtr<DisplayList> displayList = adoptRef(new DisplayList(bounds)); | 482 RefPtr<DisplayList> displayList = adoptRef(new DisplayList(bounds)); |
| 483 | 483 |
| 484 SkCanvas* savedCanvas = m_canvas; | 484 SkCanvas* savedCanvas = m_canvas; |
| 485 SkMatrix savedMatrix = getTotalMatrix(); | 485 SkMatrix savedMatrix = getTotalMatrix(); |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 | 1826 |
| 1827 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1827 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
| 1828 { | 1828 { |
| 1829 if (m_trackTextRegion) { | 1829 if (m_trackTextRegion) { |
| 1830 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); | 1830 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); |
| 1831 m_textRegion.join(textRect); | 1831 m_textRegion.join(textRect); |
| 1832 } | 1832 } |
| 1833 } | 1833 } |
| 1834 | 1834 |
| 1835 } | 1835 } |
| OLD | NEW |