| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 return m_imageBuffer.get(); | 114 return m_imageBuffer.get(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS
tate& exceptionState) | 117 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS
tate& exceptionState) |
| 118 { | 118 { |
| 119 if (!imageBuffer()) | 119 if (!imageBuffer()) |
| 120 return nullptr; | 120 return nullptr; |
| 121 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferAccelerati
on, SnapshotReasonTransferToImageBitmap); | 121 sk_sp<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferAcceleratio
n, 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(std::move(skImag
e)); |
| 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 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc
reenRenderingContext& result) | 130 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc
reenRenderingContext& result) |
| 131 { | 131 { |
| 132 result.setOffscreenCanvasRenderingContext2D(this); | 132 result.setOffscreenCanvasRenderingContext2D(this); |
| 133 } | 133 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 bool OffscreenCanvasRenderingContext2D::isContextLost() const | 192 bool OffscreenCanvasRenderingContext2D::isContextLost() const |
| 193 { | 193 { |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool OffscreenCanvasRenderingContext2D::isPaintable() const | 197 bool OffscreenCanvasRenderingContext2D::isPaintable() const |
| 198 { | 198 { |
| 199 return this->imageBuffer(); | 199 return this->imageBuffer(); |
| 200 } | 200 } |
| 201 } | 201 } |
| OLD | NEW |