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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 void OffscreenCanvasRenderingContext2D::setOriginTainted() { | 72 void OffscreenCanvasRenderingContext2D::setOriginTainted() { |
73 return offscreenCanvas()->setOriginTainted(); | 73 return offscreenCanvas()->setOriginTainted(); |
74 } | 74 } |
75 | 75 |
76 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin( | 76 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin( |
77 CanvasImageSource* source, | 77 CanvasImageSource* source, |
78 ExecutionContext* executionContext) { | 78 ExecutionContext* executionContext) { |
79 if (executionContext->isWorkerGlobalScope()) { | 79 if (executionContext->isWorkerGlobalScope()) { |
80 // We only support passing in ImageBitmap and OffscreenCanvases as source | 80 // We only support passing in ImageBitmap and OffscreenCanvases as |
81 // images in drawImage() or createPattern() in a OffscreenCanvas2d in | 81 // source images in drawImage() or createPattern() in a |
82 // worker. | 82 // OffscreenCanvas2d in worker. |
83 DCHECK(source->isImageBitmap() || source->isOffscreenCanvas()); | 83 DCHECK(source->isImageBitmap() || source->isOffscreenCanvas()); |
84 } | 84 } |
85 | 85 |
86 return CanvasRenderingContext::wouldTaintOrigin( | 86 return CanvasRenderingContext::wouldTaintOrigin( |
87 source, executionContext->getSecurityOrigin()); | 87 source, executionContext->getSecurityOrigin()); |
88 } | 88 } |
89 | 89 |
90 int OffscreenCanvasRenderingContext2D::width() const { | 90 int OffscreenCanvasRenderingContext2D::width() const { |
91 return offscreenCanvas()->width(); | 91 return offscreenCanvas()->width(); |
92 } | 92 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 AffineTransform OffscreenCanvasRenderingContext2D::baseTransform() const { | 221 AffineTransform OffscreenCanvasRenderingContext2D::baseTransform() const { |
222 if (!m_imageBuffer) | 222 if (!m_imageBuffer) |
223 return AffineTransform(); // identity | 223 return AffineTransform(); // identity |
224 return m_imageBuffer->baseTransform(); | 224 return m_imageBuffer->baseTransform(); |
225 } | 225 } |
226 | 226 |
227 void OffscreenCanvasRenderingContext2D::didDraw(const SkIRect& dirtyRect) {} | 227 void OffscreenCanvasRenderingContext2D::didDraw(const SkIRect& dirtyRect) {} |
228 | 228 |
229 bool OffscreenCanvasRenderingContext2D::stateHasFilter() { | 229 bool OffscreenCanvasRenderingContext2D::stateHasFilter() { |
230 // TODO: crbug.com/593838 make hasFilter accept nullptr | 230 return state().hasFilterForOffscreenCanvas(offscreenCanvas()->size()); |
231 // return state().hasFilter(nullptr, nullptr, IntSize(width(), height()), | |
232 // this); | |
233 return false; | |
234 } | 231 } |
235 | 232 |
236 sk_sp<SkImageFilter> OffscreenCanvasRenderingContext2D::stateGetFilter() { | 233 sk_sp<SkImageFilter> OffscreenCanvasRenderingContext2D::stateGetFilter() { |
237 // TODO: make getFilter accept nullptr | 234 return state().getFilterForOffscreenCanvas(offscreenCanvas()->size()); |
238 // return state().getFilter(nullptr, nullptr, IntSize(width(), height()), | |
239 // this); | |
240 return nullptr; | |
241 } | 235 } |
242 | 236 |
243 void OffscreenCanvasRenderingContext2D::validateStateStack() const { | 237 void OffscreenCanvasRenderingContext2D::validateStateStack() const { |
244 #if DCHECK_IS_ON() | 238 #if DCHECK_IS_ON() |
245 if (SkCanvas* skCanvas = existingDrawingCanvas()) { | 239 if (SkCanvas* skCanvas = existingDrawingCanvas()) { |
246 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), | 240 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), |
247 m_stateStack.size() + 1); | 241 m_stateStack.size() + 1); |
248 } | 242 } |
249 #endif | 243 #endif |
250 } | 244 } |
251 | 245 |
252 bool OffscreenCanvasRenderingContext2D::isContextLost() const { | 246 bool OffscreenCanvasRenderingContext2D::isContextLost() const { |
253 return false; | 247 return false; |
254 } | 248 } |
255 | 249 |
256 bool OffscreenCanvasRenderingContext2D::isPaintable() const { | 250 bool OffscreenCanvasRenderingContext2D::isPaintable() const { |
257 return this->imageBuffer(); | 251 return this->imageBuffer(); |
258 } | 252 } |
259 } | 253 } |
OLD | NEW |