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

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

Issue 1881563003: Implement OffscreenCanvas.getContext('webgl') (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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/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"
11 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
12 12
13 #define UNIMPLEMENTED ASSERT_NOT_REACHED 13 #define UNIMPLEMENTED ASSERT_NOT_REACHED
14 14
15 namespace blink { 15 namespace blink {
16 16
17 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() 17 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D()
18 { 18 {
19 } 19 }
20 20
21 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D(OffscreenCa nvas* canvas, const CanvasContextCreationAttributes& attrs) 21 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D(OffscreenCa nvas* canvas, const CanvasContextCreationAttributes& attrs)
22 : CanvasRenderingContext(canvas) 22 : CanvasRenderingContext(static_cast<HTMLCanvasElement*>(nullptr), canvas)
haraken 2016/04/28 11:14:50 Is the static_cast needed?
23 , m_hasAlpha(attrs.alpha()) 23 , m_hasAlpha(attrs.alpha())
24 { 24 {
25 } 25 }
26 26
27 DEFINE_TRACE(OffscreenCanvasRenderingContext2D) 27 DEFINE_TRACE(OffscreenCanvasRenderingContext2D)
28 { 28 {
29 CanvasRenderingContext::trace(visitor); 29 CanvasRenderingContext::trace(visitor);
30 BaseRenderingContext2D::trace(visitor); 30 BaseRenderingContext2D::trace(visitor);
31 } 31 }
32 32
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 { 88 {
89 if (!imageBuffer()) 89 if (!imageBuffer())
90 return nullptr; 90 return nullptr;
91 // TODO: crbug.com/593514 Add support for GPU rendering 91 // TODO: crbug.com/593514 Add support for GPU rendering
92 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera tion, SnapshotReasonUnknown); 92 RefPtr<SkImage> skImage = m_imageBuffer->newSkImageSnapshot(PreferNoAccelera tion, SnapshotReasonUnknown);
93 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( )); 93 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(skImage.release( ));
94 m_imageBuffer.clear(); // "Transfer" means no retained buffer 94 m_imageBuffer.clear(); // "Transfer" means no retained buffer
95 return ImageBitmap::create(image.release()); 95 return ImageBitmap::create(image.release());
96 } 96 }
97 97
98 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result)
99 {
100 result.setOffscreenCanvasRenderingContext2D(this);
101 }
102
98 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const 103 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const
99 { 104 {
100 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); 105 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr);
101 } 106 }
102 107
103 SkCanvas* OffscreenCanvasRenderingContext2D::drawingCanvas() const 108 SkCanvas* OffscreenCanvasRenderingContext2D::drawingCanvas() const
104 { 109 {
105 ImageBuffer* buffer = imageBuffer(); 110 ImageBuffer* buffer = imageBuffer();
106 if (!buffer) 111 if (!buffer)
107 return nullptr; 112 return nullptr;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 156 }
152 #endif 157 #endif
153 } 158 }
154 159
155 bool OffscreenCanvasRenderingContext2D::isContextLost() const 160 bool OffscreenCanvasRenderingContext2D::isContextLost() const
156 { 161 {
157 return false; 162 return false;
158 } 163 }
159 164
160 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698