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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 void OffscreenCanvasRenderingContext2D::setOriginTainted() { | 68 void OffscreenCanvasRenderingContext2D::setOriginTainted() { |
69 return getOffscreenCanvas()->setOriginTainted(); | 69 return getOffscreenCanvas()->setOriginTainted(); |
70 } | 70 } |
71 | 71 |
72 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin( | 72 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin( |
73 CanvasImageSource* source, | 73 CanvasImageSource* source, |
74 ExecutionContext* executionContext) { | 74 ExecutionContext* executionContext) { |
75 if (executionContext->isWorkerGlobalScope()) { | 75 if (executionContext->isWorkerGlobalScope()) { |
76 // We only support passing in ImageBitmap and OffscreenCanvases as source im
ages | 76 // We only support passing in ImageBitmap and OffscreenCanvases as source |
77 // in drawImage() or createPattern() in a OffscreenCanvas2d in worker. | 77 // images in drawImage() or createPattern() in a OffscreenCanvas2d in |
| 78 // worker. |
78 DCHECK(source->isImageBitmap() || source->isOffscreenCanvas()); | 79 DCHECK(source->isImageBitmap() || source->isOffscreenCanvas()); |
79 } | 80 } |
80 | 81 |
81 return CanvasRenderingContext::wouldTaintOrigin( | 82 return CanvasRenderingContext::wouldTaintOrigin( |
82 source, executionContext->getSecurityOrigin()); | 83 source, executionContext->getSecurityOrigin()); |
83 } | 84 } |
84 | 85 |
85 int OffscreenCanvasRenderingContext2D::width() const { | 86 int OffscreenCanvasRenderingContext2D::width() const { |
86 return getOffscreenCanvas()->width(); | 87 return getOffscreenCanvas()->width(); |
87 } | 88 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 AffineTransform OffscreenCanvasRenderingContext2D::baseTransform() const { | 186 AffineTransform OffscreenCanvasRenderingContext2D::baseTransform() const { |
186 if (!m_imageBuffer) | 187 if (!m_imageBuffer) |
187 return AffineTransform(); // identity | 188 return AffineTransform(); // identity |
188 return m_imageBuffer->baseTransform(); | 189 return m_imageBuffer->baseTransform(); |
189 } | 190 } |
190 | 191 |
191 void OffscreenCanvasRenderingContext2D::didDraw(const SkIRect& dirtyRect) {} | 192 void OffscreenCanvasRenderingContext2D::didDraw(const SkIRect& dirtyRect) {} |
192 | 193 |
193 bool OffscreenCanvasRenderingContext2D::stateHasFilter() { | 194 bool OffscreenCanvasRenderingContext2D::stateHasFilter() { |
194 // TODO: crbug.com/593838 make hasFilter accept nullptr | 195 // TODO: crbug.com/593838 make hasFilter accept nullptr |
195 // return state().hasFilter(nullptr, nullptr, IntSize(width(), height()), this
); | 196 // return state().hasFilter(nullptr, nullptr, IntSize(width(), height()), |
| 197 // this); |
196 return false; | 198 return false; |
197 } | 199 } |
198 | 200 |
199 SkImageFilter* OffscreenCanvasRenderingContext2D::stateGetFilter() { | 201 SkImageFilter* OffscreenCanvasRenderingContext2D::stateGetFilter() { |
200 // TODO: make getFilter accept nullptr | 202 // TODO: make getFilter accept nullptr |
201 // return state().getFilter(nullptr, nullptr, IntSize(width(), height()), this
); | 203 // return state().getFilter(nullptr, nullptr, IntSize(width(), height()), |
| 204 // this); |
202 return nullptr; | 205 return nullptr; |
203 } | 206 } |
204 | 207 |
205 void OffscreenCanvasRenderingContext2D::validateStateStack() const { | 208 void OffscreenCanvasRenderingContext2D::validateStateStack() const { |
206 #if ENABLE(ASSERT) | 209 #if ENABLE(ASSERT) |
207 SkCanvas* skCanvas = existingDrawingCanvas(); | 210 SkCanvas* skCanvas = existingDrawingCanvas(); |
208 if (skCanvas) { | 211 if (skCanvas) { |
209 ASSERT(static_cast<size_t>(skCanvas->getSaveCount()) == | 212 ASSERT(static_cast<size_t>(skCanvas->getSaveCount()) == |
210 m_stateStack.size()); | 213 m_stateStack.size()); |
211 } | 214 } |
212 #endif | 215 #endif |
213 } | 216 } |
214 | 217 |
215 bool OffscreenCanvasRenderingContext2D::isContextLost() const { | 218 bool OffscreenCanvasRenderingContext2D::isContextLost() const { |
216 return false; | 219 return false; |
217 } | 220 } |
218 | 221 |
219 bool OffscreenCanvasRenderingContext2D::isPaintable() const { | 222 bool OffscreenCanvasRenderingContext2D::isPaintable() const { |
220 return this->imageBuffer(); | 223 return this->imageBuffer(); |
221 } | 224 } |
222 } | 225 } |
OLD | NEW |