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

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

Powered by Google App Engine
This is Rietveld 408576698