| 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 SkCanvas* m_savedCanvas; | 109 SkCanvas* m_savedCanvas; |
| 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) | |
| 120 #if ENABLE(ASSERT) | 119 #if ENABLE(ASSERT) |
| 121 , m_annotationCount(0) | |
| 122 , m_layerCount(0) | 120 , m_layerCount(0) |
| 123 , m_disableDestructionChecks(false) | 121 , m_disableDestructionChecks(false) |
| 124 #endif | 122 #endif |
| 125 , m_disabledState(disableContextOrPainting) | 123 , m_disabledState(disableContextOrPainting) |
| 126 , m_deviceScaleFactor(1.0f) | 124 , m_deviceScaleFactor(1.0f) |
| 127 , m_regionTrackingMode(RegionTrackingDisabled) | 125 , m_regionTrackingMode(RegionTrackingDisabled) |
| 128 , m_trackTextRegion(false) | 126 , m_trackTextRegion(false) |
| 129 , m_accelerated(false) | 127 , m_accelerated(false) |
| 130 , m_isCertainlyOpaque(true) | 128 , m_isCertainlyOpaque(true) |
| 131 , m_antialiasHairlineImages(false) | 129 , m_antialiasHairlineImages(false) |
| 132 , m_shouldSmoothFonts(true) | 130 , m_shouldSmoothFonts(true) |
| 133 { | 131 { |
| 134 ASSERT(canvas); | 132 ASSERT(canvas); |
| 135 | 133 |
| 136 // FIXME: Do some tests to determine how many states are typically used, and
allocate | 134 // FIXME: Do some tests to determine how many states are typically used, and
allocate |
| 137 // several here. | 135 // several here. |
| 138 m_paintStateStack.append(GraphicsContextState::create()); | 136 m_paintStateStack.append(GraphicsContextState::create()); |
| 139 m_paintState = m_paintStateStack.last().get(); | 137 m_paintState = m_paintStateStack.last().get(); |
| 140 } | 138 } |
| 141 | 139 |
| 142 GraphicsContext::~GraphicsContext() | 140 GraphicsContext::~GraphicsContext() |
| 143 { | 141 { |
| 144 #if ENABLE(ASSERT) | 142 #if ENABLE(ASSERT) |
| 145 if (!m_disableDestructionChecks) { | 143 if (!m_disableDestructionChecks) { |
| 146 ASSERT(!m_paintStateIndex); | 144 ASSERT(!m_paintStateIndex); |
| 147 ASSERT(!m_paintState->saveCount()); | 145 ASSERT(!m_paintState->saveCount()); |
| 148 ASSERT(!m_annotationCount); | |
| 149 ASSERT(!m_layerCount); | 146 ASSERT(!m_layerCount); |
| 150 ASSERT(m_recordingStateStack.isEmpty()); | 147 ASSERT(m_recordingStateStack.isEmpty()); |
| 151 ASSERT(m_canvasStateStack.isEmpty()); | 148 ASSERT(m_canvasStateStack.isEmpty()); |
| 152 } | 149 } |
| 153 #endif | 150 #endif |
| 154 } | 151 } |
| 155 | 152 |
| 156 void GraphicsContext::resetCanvas(SkCanvas* canvas) | 153 void GraphicsContext::resetCanvas(SkCanvas* canvas) |
| 157 { | 154 { |
| 158 ASSERT(canvas); | 155 ASSERT(canvas); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void GraphicsContext::restoreLayer() | 215 void GraphicsContext::restoreLayer() |
| 219 { | 216 { |
| 220 if (contextDisabled()) | 217 if (contextDisabled()) |
| 221 return; | 218 return; |
| 222 | 219 |
| 223 m_canvas->restore(); | 220 m_canvas->restore(); |
| 224 if (regionTrackingEnabled()) | 221 if (regionTrackingEnabled()) |
| 225 m_trackedRegion.popCanvasLayer(this); | 222 m_trackedRegion.popCanvasLayer(this); |
| 226 } | 223 } |
| 227 | 224 |
| 228 void GraphicsContext::beginAnnotation(const AnnotationList& annotations) | |
| 229 { | |
| 230 if (contextDisabled()) | |
| 231 return; | |
| 232 | |
| 233 canvas()->beginCommentGroup("GraphicsContextAnnotation"); | |
| 234 | |
| 235 AnnotationList::const_iterator end = annotations.end(); | |
| 236 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i
t) | |
| 237 canvas()->addComment(it->first, it->second.ascii().data()); | |
| 238 | |
| 239 #if ENABLE(ASSERT) | |
| 240 ++m_annotationCount; | |
| 241 #endif | |
| 242 } | |
| 243 | |
| 244 void GraphicsContext::endAnnotation() | |
| 245 { | |
| 246 if (contextDisabled()) | |
| 247 return; | |
| 248 | |
| 249 ASSERT(m_annotationCount > 0); | |
| 250 canvas()->endCommentGroup(); | |
| 251 | |
| 252 #if ENABLE(ASSERT) | |
| 253 --m_annotationCount; | |
| 254 #endif | |
| 255 } | |
| 256 | |
| 257 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) | 225 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) |
| 258 { | 226 { |
| 259 if (contextDisabled()) | 227 if (contextDisabled()) |
| 260 return; | 228 return; |
| 261 | 229 |
| 262 ASSERT(pattern); | 230 ASSERT(pattern); |
| 263 if (!pattern) { | 231 if (!pattern) { |
| 264 setStrokeColor(Color::black); | 232 setStrokeColor(Color::black); |
| 265 return; | 233 return; |
| 266 } | 234 } |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag | 1801 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag |
| 1834 // being set to true). We need to decide if we respect InterpolationNone | 1802 // being set to true). We need to decide if we respect InterpolationNone |
| 1835 // being returned from computeInterpolationQuality. | 1803 // being returned from computeInterpolationQuality. |
| 1836 resampling = InterpolationLow; | 1804 resampling = InterpolationLow; |
| 1837 } | 1805 } |
| 1838 resampling = limitInterpolationQuality(this, resampling); | 1806 resampling = limitInterpolationQuality(this, resampling); |
| 1839 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); | 1807 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); |
| 1840 } | 1808 } |
| 1841 | 1809 |
| 1842 } // namespace blink | 1810 } // namespace blink |
| OLD | NEW |