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

Side by Side Diff: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp

Issue 2294963002: Submit Compositor Frame from OffscreenCanvas on main (Closed)
Patch Set: a test to ensure resizing on transferred offscreencanvas has no effect Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/offscreencanvas/OffscreenCanvas.h" 5 #include "core/offscreencanvas/OffscreenCanvas.h"
6 6
7 #include "core/dom/ExceptionCode.h" 7 #include "core/dom/ExceptionCode.h"
8 #include "core/html/canvas/CanvasContextCreationAttributes.h" 8 #include "core/html/canvas/CanvasContextCreationAttributes.h"
9 #include "core/html/canvas/CanvasRenderingContext.h" 9 #include "core/html/canvas/CanvasRenderingContext.h"
10 #include "core/html/canvas/CanvasRenderingContextFactory.h" 10 #include "core/html/canvas/CanvasRenderingContextFactory.h"
11 #include "platform/graphics/ImageBuffer.h" 11 #include "platform/graphics/ImageBuffer.h"
12 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h"
12 #include "wtf/MathExtras.h" 13 #include "wtf/MathExtras.h"
13 #include <memory> 14 #include <memory>
14 15
15 namespace blink { 16 namespace blink {
16 17
17 OffscreenCanvas::OffscreenCanvas(const IntSize& size) 18 OffscreenCanvas::OffscreenCanvas(const IntSize& size)
18 : m_size(size) 19 : m_size(size)
19 , m_originClean(true) 20 , m_originClean(true)
20 { 21 {
21 } 22 }
22 23
23 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) 24 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height)
24 { 25 {
25 return new OffscreenCanvas(IntSize(clampTo<int>(width), clampTo<int>(height) )); 26 return new OffscreenCanvas(IntSize(clampTo<int>(width), clampTo<int>(height) ));
26 } 27 }
27 28
28 void OffscreenCanvas::setWidth(unsigned width) 29 void OffscreenCanvas::setWidth(unsigned width)
29 { 30 {
31 // If this OffscreenCanvas is transferred control by an html canvas,
32 // its size is determined by html canvas's size and cannot be resized.
33 if (m_canvasId >= 0)
34 return;
30 m_size.setWidth(clampTo<int>(width)); 35 m_size.setWidth(clampTo<int>(width));
31 } 36 }
32 37
33 void OffscreenCanvas::setHeight(unsigned height) 38 void OffscreenCanvas::setHeight(unsigned height)
34 { 39 {
40 // Same comment as above.
41 if (m_canvasId >= 0)
42 return;
35 m_size.setHeight(clampTo<int>(height)); 43 m_size.setHeight(clampTo<int>(height));
36 } 44 }
37 45
38 void OffscreenCanvas::setNeutered() 46 void OffscreenCanvas::setNeutered()
39 { 47 {
40 ASSERT(!m_context); 48 ASSERT(!m_context);
41 m_isNeutered = true; 49 m_isNeutered = true;
42 m_size.setWidth(0); 50 m_size.setWidth(0);
43 m_size.setHeight(0); 51 m_size.setHeight(0);
44 } 52 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return m_originClean && !m_disableReadingFromCanvas; 135 return m_originClean && !m_disableReadingFromCanvas;
128 } 136 }
129 137
130 bool OffscreenCanvas::isPaintable() const 138 bool OffscreenCanvas::isPaintable() const
131 { 139 {
132 if (!m_context) 140 if (!m_context)
133 return ImageBuffer::canCreateImageBuffer(m_size); 141 return ImageBuffer::canCreateImageBuffer(m_size);
134 return m_context->isPaintable(); 142 return m_context->isPaintable();
135 } 143 }
136 144
145 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher()
146 {
147 if (!m_frameDispatcher)
148 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl(m_ clientId, m_localId, m_nonce, width(), height()));
149 return m_frameDispatcher.get();
150 }
151
137 DEFINE_TRACE(OffscreenCanvas) 152 DEFINE_TRACE(OffscreenCanvas)
138 { 153 {
139 visitor->trace(m_context); 154 visitor->trace(m_context);
140 } 155 }
141 156
142 } // namespace blink 157 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698