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/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
9 #include "core/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 bool OffscreenCanvasRenderingContext2D::HasImageBuffer() const { | 90 bool OffscreenCanvasRenderingContext2D::HasImageBuffer() const { |
91 return host()->GetImageBuffer(); | 91 return host()->GetImageBuffer(); |
92 } | 92 } |
93 | 93 |
94 void OffscreenCanvasRenderingContext2D::Reset() { | 94 void OffscreenCanvasRenderingContext2D::Reset() { |
95 host()->DiscardImageBuffer(); | 95 host()->DiscardImageBuffer(); |
96 BaseRenderingContext2D::Reset(); | 96 BaseRenderingContext2D::Reset(); |
97 } | 97 } |
98 | 98 |
99 ColorBehavior OffscreenCanvasRenderingContext2D::DrawImageColorBehavior() | |
100 const { | |
101 return CanvasRenderingContext::ColorBehaviorForMediaDrawnToCanvas(); | |
102 } | |
103 | |
104 ImageBuffer* OffscreenCanvasRenderingContext2D::GetImageBuffer() const { | 99 ImageBuffer* OffscreenCanvasRenderingContext2D::GetImageBuffer() const { |
105 return const_cast<CanvasRenderingContextHost*>(host()) | 100 return const_cast<CanvasRenderingContextHost*>(host()) |
106 ->GetOrCreateImageBuffer(); | 101 ->GetOrCreateImageBuffer(); |
107 } | 102 } |
108 | 103 |
109 RefPtr<StaticBitmapImage> | 104 RefPtr<StaticBitmapImage> |
110 OffscreenCanvasRenderingContext2D::TransferToStaticBitmapImage() { | 105 OffscreenCanvasRenderingContext2D::TransferToStaticBitmapImage() { |
111 if (!GetImageBuffer()) | 106 if (!GetImageBuffer()) |
112 return nullptr; | 107 return nullptr; |
113 sk_sp<SkImage> sk_image = GetImageBuffer()->NewSkImageSnapshot( | 108 sk_sp<SkImage> sk_image = GetImageBuffer()->NewSkImageSnapshot( |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 223 } |
229 | 224 |
230 CanvasPixelFormat OffscreenCanvasRenderingContext2D::PixelFormat() const { | 225 CanvasPixelFormat OffscreenCanvasRenderingContext2D::PixelFormat() const { |
231 return color_params().pixel_format(); | 226 return color_params().pixel_format(); |
232 } | 227 } |
233 | 228 |
234 bool OffscreenCanvasRenderingContext2D::IsAccelerated() const { | 229 bool OffscreenCanvasRenderingContext2D::IsAccelerated() const { |
235 return HasImageBuffer() && GetImageBuffer()->IsAccelerated(); | 230 return HasImageBuffer() && GetImageBuffer()->IsAccelerated(); |
236 } | 231 } |
237 } | 232 } |
OLD | NEW |