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

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

Issue 2420203002: Implement convertToBlob() in OffscreenCanvas (Closed)
Patch Set: rebase and fix global-interface-listing-service-worker-expected.txt Created 4 years, 2 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 AccelerationHint hint, 151 AccelerationHint hint,
152 SnapshotReason reason) const { 152 SnapshotReason reason) const {
153 if (!imageBuffer()) 153 if (!imageBuffer())
154 return nullptr; 154 return nullptr;
155 sk_sp<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(hint, reason); 155 sk_sp<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(hint, reason);
156 RefPtr<StaticBitmapImage> image = 156 RefPtr<StaticBitmapImage> image =
157 StaticBitmapImage::create(std::move(skImage)); 157 StaticBitmapImage::create(std::move(skImage));
158 return image; 158 return image;
159 } 159 }
160 160
161 ImageData* OffscreenCanvasRenderingContext2D::toImageData(
162 SnapshotReason reason) const {
163 if (!imageBuffer())
164 return nullptr;
165 sk_sp<SkImage> snapshot =
166 m_imageBuffer->newSkImageSnapshot(PreferNoAcceleration, reason);
167 ImageData* imageData = nullptr;
168 if (snapshot) {
169 imageData = ImageData::create(this->getOffscreenCanvas()->size());
170 SkImageInfo imageInfo =
171 SkImageInfo::Make(this->width(), this->height(), kRGBA_8888_SkColorType,
172 kUnpremul_SkAlphaType);
173 snapshot->readPixels(imageInfo, imageData->data()->data(),
174 imageInfo.minRowBytes(), 0, 0);
175 }
176 return imageData;
177 }
178
161 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult( 179 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(
162 OffscreenRenderingContext& result) { 180 OffscreenRenderingContext& result) {
163 result.setOffscreenCanvasRenderingContext2D(this); 181 result.setOffscreenCanvasRenderingContext2D(this);
164 } 182 }
165 183
166 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor( 184 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(
167 Color& color, 185 Color& color,
168 const String& colorString) const { 186 const String& colorString) const {
169 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); 187 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr);
170 } 188 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 235 }
218 236
219 bool OffscreenCanvasRenderingContext2D::isContextLost() const { 237 bool OffscreenCanvasRenderingContext2D::isContextLost() const {
220 return false; 238 return false;
221 } 239 }
222 240
223 bool OffscreenCanvasRenderingContext2D::isPaintable() const { 241 bool OffscreenCanvasRenderingContext2D::isPaintable() const {
224 return this->imageBuffer(); 242 return this->imageBuffer();
225 } 243 }
226 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698