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

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

Issue 2849463005: Refactor ImageBuffer to make OffscreenCanvas match HTMLCanvasElement (Closed)
Patch Set: x Created 3 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 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 #ifndef OffscreenCanvas_h 5 #ifndef OffscreenCanvas_h
6 #define OffscreenCanvas_h 6 #define OffscreenCanvas_h
7 7
8 #include <memory> 8 #include <memory>
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
11 #include "bindings/core/v8/ScriptWrappable.h" 11 #include "bindings/core/v8/ScriptWrappable.h"
12 #include "core/events/EventTarget.h" 12 #include "core/events/EventTarget.h"
13 #include "core/html/HTMLCanvasElement.h" 13 #include "core/html/HTMLCanvasElement.h"
14 #include "core/html/canvas/CanvasImageSource.h" 14 #include "core/html/canvas/CanvasImageSource.h"
15 #include "core/html/canvas/CanvasRenderingContextHost.h" 15 #include "core/html/canvas/CanvasRenderingContextHost.h"
16 #include "core/imagebitmap/ImageBitmapSource.h"
16 #include "core/offscreencanvas/ImageEncodeOptions.h" 17 #include "core/offscreencanvas/ImageEncodeOptions.h"
17 #include "platform/geometry/IntSize.h" 18 #include "platform/geometry/IntSize.h"
18 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" 19 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h"
19 #include "platform/heap/Handle.h" 20 #include "platform/heap/Handle.h"
20 21
21 namespace blink { 22 namespace blink {
22 23
23 class CanvasContextCreationAttributes; 24 class CanvasContextCreationAttributes;
24 class ImageBitmap; 25 class ImageBitmap;
25 class 26 class
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 static void RegisterRenderingContextFactory( 77 static void RegisterRenderingContextFactory(
77 std::unique_ptr<CanvasRenderingContextFactory>); 78 std::unique_ptr<CanvasRenderingContextFactory>);
78 79
79 bool OriginClean() const; 80 bool OriginClean() const;
80 void SetOriginTainted() { origin_clean_ = false; } 81 void SetOriginTainted() { origin_clean_ = false; }
81 // TODO(crbug.com/630356): apply the flag to WebGL context as well 82 // TODO(crbug.com/630356): apply the flag to WebGL context as well
82 void SetDisableReadingFromCanvasTrue() { 83 void SetDisableReadingFromCanvasTrue() {
83 disable_reading_from_canvas_ = true; 84 disable_reading_from_canvas_ = true;
84 } 85 }
85 86
87 bool HasImageBuffer() const override { return !!image_buffer_; }
88 void DiscardImageBuffer() override;
89 ImageBuffer* GetImageBuffer() const override;
90
86 void SetFrameSinkId(uint32_t client_id, uint32_t sink_id) { 91 void SetFrameSinkId(uint32_t client_id, uint32_t sink_id) {
87 client_id_ = client_id; 92 client_id_ = client_id;
88 sink_id_ = sink_id; 93 sink_id_ = sink_id;
89 } 94 }
90 uint32_t ClientId() const { return client_id_; } 95 uint32_t ClientId() const { return client_id_; }
91 uint32_t SinkId() const { return sink_id_; } 96 uint32_t SinkId() const { return sink_id_; }
92 97
93 void SetExecutionContext(ExecutionContext* context) { 98 void SetExecutionContext(ExecutionContext* context) {
94 execution_context_ = context; 99 execution_context_ = context;
95 } 100 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 bool disable_reading_from_canvas_ = false; 179 bool disable_reading_from_canvas_ = false;
175 180
176 bool IsPaintable() const; 181 bool IsPaintable() const;
177 182
178 std::unique_ptr<OffscreenCanvasFrameDispatcher> frame_dispatcher_; 183 std::unique_ptr<OffscreenCanvasFrameDispatcher> frame_dispatcher_;
179 184
180 Member<ScriptPromiseResolver> commit_promise_resolver_; 185 Member<ScriptPromiseResolver> commit_promise_resolver_;
181 RefPtr<StaticBitmapImage> current_frame_; 186 RefPtr<StaticBitmapImage> current_frame_;
182 bool current_frame_is_web_gl_software_rendering_ = false; 187 bool current_frame_is_web_gl_software_rendering_ = false;
183 188
189 std::unique_ptr<ImageBuffer> image_buffer_;
190 bool needs_matrix_clip_restore_ = false;
191
184 // cc::FrameSinkId is broken into two integer components as this can be used 192 // cc::FrameSinkId is broken into two integer components as this can be used
185 // in transfer of OffscreenCanvas across threads 193 // in transfer of OffscreenCanvas across threads
186 // If this object is not created via 194 // If this object is not created via
187 // HTMLCanvasElement.transferControlToOffscreen(), 195 // HTMLCanvasElement.transferControlToOffscreen(),
188 // then the following members would remain as initialized zero values. 196 // then the following members would remain as initialized zero values.
189 uint32_t client_id_ = 0; 197 uint32_t client_id_ = 0;
190 uint32_t sink_id_ = 0; 198 uint32_t sink_id_ = 0;
191 }; 199 };
192 200
193 } // namespace blink 201 } // namespace blink
194 202
195 #endif // OffscreenCanvas_h 203 #endif // OffscreenCanvas_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698