| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "wtf/MathExtras.h" | 51 #include "wtf/MathExtras.h" |
| 52 #include <memory> | 52 #include <memory> |
| 53 | 53 |
| 54 namespace blink { | 54 namespace blink { |
| 55 | 55 |
| 56 GraphicsContext::GraphicsContext(PaintController& paintController, DisabledMode
disableContextOrPainting, SkMetaData* metaData) | 56 GraphicsContext::GraphicsContext(PaintController& paintController, DisabledMode
disableContextOrPainting, SkMetaData* metaData) |
| 57 : m_canvas(nullptr) | 57 : m_canvas(nullptr) |
| 58 , m_paintController(paintController) | 58 , m_paintController(paintController) |
| 59 , m_paintStateStack() | 59 , m_paintStateStack() |
| 60 , m_paintStateIndex(0) | 60 , m_paintStateIndex(0) |
| 61 #if ENABLE(ASSERT) | 61 #if DCHECK_IS_ON() |
| 62 , m_layerCount(0) | 62 , m_layerCount(0) |
| 63 , m_disableDestructionChecks(false) | 63 , m_disableDestructionChecks(false) |
| 64 , m_inDrawingRecorder(false) | 64 , m_inDrawingRecorder(false) |
| 65 #endif | 65 #endif |
| 66 , m_disabledState(disableContextOrPainting) | 66 , m_disabledState(disableContextOrPainting) |
| 67 , m_deviceScaleFactor(1.0f) | 67 , m_deviceScaleFactor(1.0f) |
| 68 , m_printing(false) | 68 , m_printing(false) |
| 69 , m_hasMetaData(!!metaData) | 69 , m_hasMetaData(!!metaData) |
| 70 { | 70 { |
| 71 if (metaData) | 71 if (metaData) |
| 72 m_metaData = *metaData; | 72 m_metaData = *metaData; |
| 73 | 73 |
| 74 // FIXME: Do some tests to determine how many states are typically used, and
allocate | 74 // FIXME: Do some tests to determine how many states are typically used, and
allocate |
| 75 // several here. | 75 // several here. |
| 76 m_paintStateStack.append(GraphicsContextState::create()); | 76 m_paintStateStack.append(GraphicsContextState::create()); |
| 77 m_paintState = m_paintStateStack.last().get(); | 77 m_paintState = m_paintStateStack.last().get(); |
| 78 | 78 |
| 79 if (contextDisabled()) { | 79 if (contextDisabled()) { |
| 80 DEFINE_STATIC_REF(SkCanvas, nullCanvas, (adoptRef(SkCreateNullCanvas()))
); | 80 DEFINE_STATIC_REF(SkCanvas, nullCanvas, (adoptRef(SkCreateNullCanvas()))
); |
| 81 m_canvas = nullCanvas; | 81 m_canvas = nullCanvas; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 GraphicsContext::~GraphicsContext() | 85 GraphicsContext::~GraphicsContext() |
| 86 { | 86 { |
| 87 #if ENABLE(ASSERT) | 87 #if DCHECK_IS_ON() |
| 88 if (!m_disableDestructionChecks) { | 88 if (!m_disableDestructionChecks) { |
| 89 ASSERT(!m_paintStateIndex); | 89 ASSERT(!m_paintStateIndex); |
| 90 ASSERT(!m_paintState->saveCount()); | 90 ASSERT(!m_paintState->saveCount()); |
| 91 ASSERT(!m_layerCount); | 91 ASSERT(!m_layerCount); |
| 92 ASSERT(!saveCount()); | 92 ASSERT(!saveCount()); |
| 93 } | 93 } |
| 94 #endif | 94 #endif |
| 95 } | 95 } |
| 96 | 96 |
| 97 void GraphicsContext::save() | 97 void GraphicsContext::save() |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void GraphicsContext::restoreLayer() | 153 void GraphicsContext::restoreLayer() |
| 154 { | 154 { |
| 155 if (contextDisabled()) | 155 if (contextDisabled()) |
| 156 return; | 156 return; |
| 157 | 157 |
| 158 ASSERT(m_canvas); | 158 ASSERT(m_canvas); |
| 159 | 159 |
| 160 m_canvas->restore(); | 160 m_canvas->restore(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 #if ENABLE(ASSERT) | 163 #if DCHECK_IS_ON() |
| 164 void GraphicsContext::setInDrawingRecorder(bool val) | 164 void GraphicsContext::setInDrawingRecorder(bool val) |
| 165 { | 165 { |
| 166 // Nested drawing recorers are not allowed. | 166 // Nested drawing recorers are not allowed. |
| 167 ASSERT(!val || !m_inDrawingRecorder); | 167 ASSERT(!val || !m_inDrawingRecorder); |
| 168 m_inDrawingRecorder = val; | 168 m_inDrawingRecorder = val; |
| 169 } | 169 } |
| 170 #endif | 170 #endif |
| 171 | 171 |
| 172 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, | 172 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, |
| 173 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, | 173 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 layerPaint.setColorFilter(toSkSp(WebCoreColorFilterToSkiaColorFilter(colorFi
lter))); | 239 layerPaint.setColorFilter(toSkSp(WebCoreColorFilterToSkiaColorFilter(colorFi
lter))); |
| 240 layerPaint.setImageFilter(std::move(imageFilter)); | 240 layerPaint.setImageFilter(std::move(imageFilter)); |
| 241 | 241 |
| 242 if (bounds) { | 242 if (bounds) { |
| 243 SkRect skBounds = *bounds; | 243 SkRect skBounds = *bounds; |
| 244 saveLayer(&skBounds, &layerPaint); | 244 saveLayer(&skBounds, &layerPaint); |
| 245 } else { | 245 } else { |
| 246 saveLayer(nullptr, &layerPaint); | 246 saveLayer(nullptr, &layerPaint); |
| 247 } | 247 } |
| 248 | 248 |
| 249 #if ENABLE(ASSERT) | 249 #if DCHECK_IS_ON() |
| 250 ++m_layerCount; | 250 ++m_layerCount; |
| 251 #endif | 251 #endif |
| 252 } | 252 } |
| 253 | 253 |
| 254 void GraphicsContext::endLayer() | 254 void GraphicsContext::endLayer() |
| 255 { | 255 { |
| 256 if (contextDisabled()) | 256 if (contextDisabled()) |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 restoreLayer(); | 259 restoreLayer(); |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 static const SkPMColor colors[] = { | 1331 static const SkPMColor colors[] = { |
| 1332 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1332 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1333 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1333 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1334 }; | 1334 }; |
| 1335 | 1335 |
| 1336 return colors[index]; | 1336 return colors[index]; |
| 1337 } | 1337 } |
| 1338 #endif | 1338 #endif |
| 1339 | 1339 |
| 1340 } // namespace blink | 1340 } // namespace blink |
| OLD | NEW |