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

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: almost identical as PS8 Created 4 years, 8 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)
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
88 void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult(Offsc reenRenderingContext& result)
89 {
90 result.setOffscreenCanvasRenderingContext2D(this);
91 }
92
88 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const 93 bool OffscreenCanvasRenderingContext2D::parseColorOrCurrentColor(Color& color, c onst String& colorString) const
89 { 94 {
90 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); 95 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr);
91 } 96 }
92 97
93 SkCanvas* OffscreenCanvasRenderingContext2D::drawingCanvas() const 98 SkCanvas* OffscreenCanvasRenderingContext2D::drawingCanvas() const
94 { 99 {
95 ImageBuffer* buffer = imageBuffer(); 100 ImageBuffer* buffer = imageBuffer();
96 if (!buffer) 101 if (!buffer)
97 return nullptr; 102 return nullptr;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 146 }
142 #endif 147 #endif
143 } 148 }
144 149
145 bool OffscreenCanvasRenderingContext2D::isContextLost() const 150 bool OffscreenCanvasRenderingContext2D::isContextLost() const
146 { 151 {
147 return false; 152 return false;
148 } 153 }
149 154
150 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698