| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 5 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" | 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" |
| 8 #include "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/workers/WorkerGlobalScope.h" | 10 #include "core/workers/WorkerGlobalScope.h" |
| 11 #include "core/workers/WorkerSettings.h" | 11 #include "core/workers/WorkerSettings.h" |
| 12 #include "platform/graphics/ImageBuffer.h" | 12 #include "platform/graphics/ImageBuffer.h" |
| 13 #include "platform/graphics/StaticBitmapImage.h" | 13 #include "platform/graphics/StaticBitmapImage.h" |
| 14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
| 16 #include "skia/ext/cdl_canvas.h" |
| 16 #include "wtf/Assertions.h" | 17 #include "wtf/Assertions.h" |
| 17 #include "wtf/CurrentTime.h" | 18 #include "wtf/CurrentTime.h" |
| 18 | 19 |
| 19 #define UNIMPLEMENTED ASSERT_NOT_REACHED | 20 #define UNIMPLEMENTED ASSERT_NOT_REACHED |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| 23 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() {} | 24 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() {} |
| 24 | 25 |
| 25 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D( | 26 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 OffscreenRenderingContext& result) { | 192 OffscreenRenderingContext& result) { |
| 192 result.setOffscreenCanvasRenderingContext2D(this); | 193 result.setOffscreenCanvasRenderingContext2D(this); |
| 193 } | 194 } |
| 194 | 195 |
| 195 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor( | 196 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor( |
| 196 Color& color, | 197 Color& color, |
| 197 const String& colorString) const { | 198 const String& colorString) const { |
| 198 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); | 199 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); |
| 199 } | 200 } |
| 200 | 201 |
| 201 SkCanvas* OffscreenCanvasRenderingContext2D::drawingCanvas() const { | 202 CdlCanvas* OffscreenCanvasRenderingContext2D::drawingCanvas() const { |
| 202 ImageBuffer* buffer = imageBuffer(); | 203 ImageBuffer* buffer = imageBuffer(); |
| 203 if (!buffer) | 204 if (!buffer) |
| 204 return nullptr; | 205 return nullptr; |
| 205 return imageBuffer()->canvas(); | 206 return imageBuffer()->canvas(); |
| 206 } | 207 } |
| 207 | 208 |
| 208 SkCanvas* OffscreenCanvasRenderingContext2D::existingDrawingCanvas() const { | 209 CdlCanvas* OffscreenCanvasRenderingContext2D::existingDrawingCanvas() const { |
| 209 if (!m_imageBuffer) | 210 if (!m_imageBuffer) |
| 210 return nullptr; | 211 return nullptr; |
| 211 return m_imageBuffer->canvas(); | 212 return m_imageBuffer->canvas(); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void OffscreenCanvasRenderingContext2D::disableDeferral(DisableDeferralReason) { | 215 void OffscreenCanvasRenderingContext2D::disableDeferral(DisableDeferralReason) { |
| 215 } | 216 } |
| 216 | 217 |
| 217 AffineTransform OffscreenCanvasRenderingContext2D::baseTransform() const { | 218 AffineTransform OffscreenCanvasRenderingContext2D::baseTransform() const { |
| 218 if (!m_imageBuffer) | 219 if (!m_imageBuffer) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 231 | 232 |
| 232 sk_sp<SkImageFilter> OffscreenCanvasRenderingContext2D::stateGetFilter() { | 233 sk_sp<SkImageFilter> OffscreenCanvasRenderingContext2D::stateGetFilter() { |
| 233 // TODO: make getFilter accept nullptr | 234 // TODO: make getFilter accept nullptr |
| 234 // return state().getFilter(nullptr, nullptr, IntSize(width(), height()), | 235 // return state().getFilter(nullptr, nullptr, IntSize(width(), height()), |
| 235 // this); | 236 // this); |
| 236 return nullptr; | 237 return nullptr; |
| 237 } | 238 } |
| 238 | 239 |
| 239 void OffscreenCanvasRenderingContext2D::validateStateStack() const { | 240 void OffscreenCanvasRenderingContext2D::validateStateStack() const { |
| 240 #if DCHECK_IS_ON() | 241 #if DCHECK_IS_ON() |
| 241 if (SkCanvas* skCanvas = existingDrawingCanvas()) { | 242 if (CdlCanvas* skCanvas = existingDrawingCanvas()) { |
| 242 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), | 243 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), |
| 243 m_stateStack.size() + 1); | 244 m_stateStack.size() + 1); |
| 244 } | 245 } |
| 245 #endif | 246 #endif |
| 246 } | 247 } |
| 247 | 248 |
| 248 bool OffscreenCanvasRenderingContext2D::isContextLost() const { | 249 bool OffscreenCanvasRenderingContext2D::isContextLost() const { |
| 249 return false; | 250 return false; |
| 250 } | 251 } |
| 251 | 252 |
| 252 bool OffscreenCanvasRenderingContext2D::isPaintable() const { | 253 bool OffscreenCanvasRenderingContext2D::isPaintable() const { |
| 253 return this->imageBuffer(); | 254 return this->imageBuffer(); |
| 254 } | 255 } |
| 255 } | 256 } |
| OLD | NEW |