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

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

Issue 2294383002: Make OffscreenCanvas a member of CanvasImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 void OffscreenCanvasRenderingContext2D::setOriginTainted() 53 void OffscreenCanvasRenderingContext2D::setOriginTainted()
54 { 54 {
55 return getOffscreenCanvas()->setOriginTainted(); 55 return getOffscreenCanvas()->setOriginTainted();
56 } 56 }
57 57
58 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin(CanvasImageSource* sour ce, ExecutionContext* executionContext) 58 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin(CanvasImageSource* sour ce, ExecutionContext* executionContext)
59 { 59 {
60 if (executionContext->isWorkerGlobalScope()) { 60 if (executionContext->isWorkerGlobalScope()) {
61 // Currently, we only support passing in ImageBitmap as source image in 61 // We only support passing in ImageBitmap and OffscreenCanvases as sourc e images
62 // drawImage() or createPattern() in a OffscreenCanvas2d in worker. 62 // in drawImage() or createPattern() in a OffscreenCanvas2d in worker.
63 ASSERT(source->isImageBitmap()); 63 DCHECK(source->isImageBitmap() || source->isOffscreenCanvas());
64 } 64 }
65 65
66 return CanvasRenderingContext::wouldTaintOrigin(source, executionContext->ge tSecurityOrigin()); 66 return CanvasRenderingContext::wouldTaintOrigin(source, executionContext->ge tSecurityOrigin());
67 } 67 }
68 68
69 int OffscreenCanvasRenderingContext2D::width() const 69 int OffscreenCanvasRenderingContext2D::width() const
70 { 70 {
71 return getOffscreenCanvas()->width(); 71 return getOffscreenCanvas()->width();
72 } 72 }
73 73
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return nullptr; 120 return nullptr;
121 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferAccelerati on, SnapshotReasonTransferToImageBitmap); 121 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferAccelerati on, SnapshotReasonTransferToImageBitmap);
122 DCHECK(isMainThread() || !skImage->isTextureBacked()); // Acceleration not y et supported in Workers 122 DCHECK(isMainThread() || !skImage->isTextureBacked()); // Acceleration not y et supported in Workers
123 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( )); 123 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( ));
124 image->setOriginClean(this->originClean()); 124 image->setOriginClean(this->originClean());
125 m_imageBuffer.reset(); // "Transfer" means no retained buffer 125 m_imageBuffer.reset(); // "Transfer" means no retained buffer
126 m_needsMatrixClipRestore = true; 126 m_needsMatrixClipRestore = true;
127 return ImageBitmap::create(image.release()); 127 return ImageBitmap::create(image.release());
128 } 128 }
129 129
130 PassRefPtr<Image> OffscreenCanvasRenderingContext2D::getImage(SnapshotReason rea son) const
131 {
132 if (!imageBuffer())
133 return nullptr;
134 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferAccelerati on, reason);
135 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( ));
136 return image;
137 }
138
130 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result) 139 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result)
131 { 140 {
132 result.setOffscreenCanvasRenderingContext2D(this); 141 result.setOffscreenCanvasRenderingContext2D(this);
133 } 142 }
134 143
135 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const 144 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const
136 { 145 {
137 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); 146 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr);
138 } 147 }
139 148
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 bool OffscreenCanvasRenderingContext2D::isContextLost() const 201 bool OffscreenCanvasRenderingContext2D::isContextLost() const
193 { 202 {
194 return false; 203 return false;
195 } 204 }
196 205
197 bool OffscreenCanvasRenderingContext2D::isPaintable() const 206 bool OffscreenCanvasRenderingContext2D::isPaintable() const
198 { 207 {
199 return this->imageBuffer(); 208 return this->imageBuffer();
200 } 209 }
201 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698