Chromium Code Reviews| 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()), | 235 } |
| 239 // this); | 236 |
| 240 return nullptr; | 237 void OffscreenCanvasRenderingContext2D::setFilter(const String& filterString) { |
| 238 BaseRenderingContext2D::setFilter(filterString); | |
|
Justin Novosad
2017/01/17 22:49:02
Ah, here it is. Why is this needed? It should not
fserb
2017/01/18 15:47:59
yep. Sorry, it was a side effect from the process.
| |
| 241 } | 239 } |
| 242 | 240 |
| 243 void OffscreenCanvasRenderingContext2D::validateStateStack() const { | 241 void OffscreenCanvasRenderingContext2D::validateStateStack() const { |
| 244 #if DCHECK_IS_ON() | 242 #if DCHECK_IS_ON() |
| 245 if (SkCanvas* skCanvas = existingDrawingCanvas()) { | 243 if (SkCanvas* skCanvas = existingDrawingCanvas()) { |
| 246 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), | 244 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), |
| 247 m_stateStack.size() + 1); | 245 m_stateStack.size() + 1); |
| 248 } | 246 } |
| 249 #endif | 247 #endif |
| 250 } | 248 } |
| 251 | 249 |
| 252 bool OffscreenCanvasRenderingContext2D::isContextLost() const { | 250 bool OffscreenCanvasRenderingContext2D::isContextLost() const { |
| 253 return false; | 251 return false; |
| 254 } | 252 } |
| 255 | 253 |
| 256 bool OffscreenCanvasRenderingContext2D::isPaintable() const { | 254 bool OffscreenCanvasRenderingContext2D::isPaintable() const { |
| 257 return this->imageBuffer(); | 255 return this->imageBuffer(); |
| 258 } | 256 } |
| 259 } | 257 } |
| OLD | NEW |