| 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/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (!m_imageBuffer) { | 67 if (!m_imageBuffer) { |
| 68 // TODO: crbug.com/593514 Add support for GPU rendering | 68 // TODO: crbug.com/593514 Add support for GPU rendering |
| 69 OffscreenCanvasRenderingContext2D* nonConstThis = const_cast<OffscreenCa
nvasRenderingContext2D*>(this); | 69 OffscreenCanvasRenderingContext2D* nonConstThis = const_cast<OffscreenCa
nvasRenderingContext2D*>(this); |
| 70 nonConstThis->m_imageBuffer = ImageBuffer::create(IntSize(width(), heigh
t()), m_hasAlpha ? NonOpaque : Opaque, InitializeImagePixels); | 70 nonConstThis->m_imageBuffer = ImageBuffer::create(IntSize(width(), heigh
t()), m_hasAlpha ? NonOpaque : Opaque, InitializeImagePixels); |
| 71 // TODO: crbug.com/593349 Restore matrix and clip state on the new Image
Buffer. | 71 // TODO: crbug.com/593349 Restore matrix and clip state on the new Image
Buffer. |
| 72 } | 72 } |
| 73 | 73 |
| 74 return m_imageBuffer.get(); | 74 return m_imageBuffer.get(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 RawPtr<ImageBitmap> OffscreenCanvasRenderingContext2D::transferToImageBitmap(Exc
eptionState& exceptionState) | 77 ImageBitmap* OffscreenCanvasRenderingContext2D::transferToImageBitmap(ExceptionS
tate& exceptionState) |
| 78 { | 78 { |
| 79 if (!imageBuffer()) | 79 if (!imageBuffer()) |
| 80 return nullptr; | 80 return nullptr; |
| 81 // TODO: crbug.com/593514 Add support for GPU rendering | 81 // TODO: crbug.com/593514 Add support for GPU rendering |
| 82 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera
tion, SnapshotReasonUnknown); | 82 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera
tion, SnapshotReasonUnknown); |
| 83 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release(
)); | 83 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release(
)); |
| 84 m_imageBuffer.clear(); // "Transfer" means no retained buffer | 84 m_imageBuffer.clear(); // "Transfer" means no retained buffer |
| 85 return ImageBitmap::create(image.release()); | 85 return ImageBitmap::create(image.release()); |
| 86 } | 86 } |
| 87 | 87 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 #endif | 142 #endif |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool OffscreenCanvasRenderingContext2D::isContextLost() const | 145 bool OffscreenCanvasRenderingContext2D::isContextLost() const |
| 146 { | 146 { |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } | 150 } |
| OLD | NEW |