Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp

Issue 1928043002: Add drawImage() originClean() getSecurityOrigin() to OffscreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put back CallWith=ScriptState Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/UnionTypesModules.h" 7 #include "bindings/modules/v8/UnionTypesModules.h"
8 #include "core/frame/ImageBitmap.h" 8 #include "core/frame/ImageBitmap.h"
9 #include "platform/graphics/ImageBuffer.h" 9 #include "platform/graphics/ImageBuffer.h"
10 #include "platform/graphics/StaticBitmapImage.h" 10 #include "platform/graphics/StaticBitmapImage.h"
(...skipping 15 matching lines...) Expand all
26 26
27 DEFINE_TRACE(OffscreenCanvasRenderingContext2D) 27 DEFINE_TRACE(OffscreenCanvasRenderingContext2D)
28 { 28 {
29 CanvasRenderingContext::trace(visitor); 29 CanvasRenderingContext::trace(visitor);
30 BaseRenderingContext2D::trace(visitor); 30 BaseRenderingContext2D::trace(visitor);
31 } 31 }
32 32
33 // BaseRenderingContext2D implementation 33 // BaseRenderingContext2D implementation
34 bool OffscreenCanvasRenderingContext2D::originClean() const 34 bool OffscreenCanvasRenderingContext2D::originClean() const
35 { 35 {
36 return m_originClean; 36 return getOffscreenCanvas()->originClean();
37 } 37 }
38 38
39 void OffscreenCanvasRenderingContext2D::setOriginTainted() 39 void OffscreenCanvasRenderingContext2D::setOriginTainted()
40 { 40 {
41 m_originClean = false; 41 return getOffscreenCanvas()->setOriginTainted();
42 } 42 }
43 43
44 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin(CanvasImageSource* sour ce, ScriptState* scriptState) 44 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin(CanvasImageSource* sour ce, ScriptState* scriptState)
45 { 45 {
46 if (scriptState->getExecutionContext()->isWorkerGlobalScope()) { 46 if (scriptState->getExecutionContext()->isWorkerGlobalScope()) {
47 // Currently, we only support passing in ImageBitmap as source image in 47 // Currently, we only support passing in ImageBitmap as source image in
48 // drawImage() or createPattern() in a OffscreenCanvas2d in worker. 48 // drawImage() or createPattern() in a OffscreenCanvas2d in worker.
49 ASSERT(source->isImageBitmap()); 49 ASSERT(source->isImageBitmap());
50 // ImageBitmap wouldTaintOrigin doesn't consider destinationSecurityOrig in. 50 // ImageBitmap wouldTaintOrigin doesn't consider destinationSecurityOrig in.
51 return source->wouldTaintOrigin(nullptr); 51 return source->wouldTaintOrigin(nullptr);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return m_imageBuffer.get(); 84 return m_imageBuffer.get();
85 } 85 }
86 86
87 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS tate& exceptionState) 87 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS tate& exceptionState)
88 { 88 {
89 if (!imageBuffer()) 89 if (!imageBuffer())
90 return nullptr; 90 return nullptr;
91 // TODO: crbug.com/593514 Add support for GPU rendering 91 // TODO: crbug.com/593514 Add support for GPU rendering
92 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera tion, SnapshotReasonUnknown); 92 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera tion, SnapshotReasonUnknown);
93 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( )); 93 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( ));
94 image->setOriginClean(this->originClean());
Justin Novosad 2016/04/29 04:08:55 This needs a test. Something like: draw a tainted
94 m_imageBuffer.clear(); // "Transfer" means no retained buffer 95 m_imageBuffer.clear(); // "Transfer" means no retained buffer
95 return ImageBitmap::create(image.release()); 96 return ImageBitmap::create(image.release());
96 } 97 }
97 98
98 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result) 99 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result)
99 { 100 {
100 result.setOffscreenCanvasRenderingContext2D(this); 101 result.setOffscreenCanvasRenderingContext2D(this);
101 } 102 }
102 103
103 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const 104 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 157 }
157 #endif 158 #endif
158 } 159 }
159 160
160 bool OffscreenCanvasRenderingContext2D::isContextLost() const 161 bool OffscreenCanvasRenderingContext2D::isContextLost() const
161 { 162 {
162 return false; 163 return false;
163 } 164 }
164 165
165 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698