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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.h

Issue 2584643002: Revamp OffscreenCanvas commit flow (Closed)
Patch Set: rebase and fix conflict Created 4 years 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 #ifndef OffscreenCanvasFrameDispatcherImpl_h 5 #ifndef OffscreenCanvasFrameDispatcherImpl_h
6 #define OffscreenCanvasFrameDispatcherImpl_h 6 #define OffscreenCanvasFrameDispatcherImpl_h
7 7
8 #include "cc/ipc/mojo_compositor_frame_sink.mojom-blink.h" 8 #include "cc/ipc/mojo_compositor_frame_sink.mojom-blink.h"
9 #include "cc/output/begin_frame_args.h" 9 #include "cc/output/begin_frame_args.h"
10 #include "cc/resources/shared_bitmap.h" 10 #include "cc/resources/shared_bitmap.h"
11 #include "cc/surfaces/surface_id.h" 11 #include "cc/surfaces/surface_id.h"
12 #include "cc/surfaces/surface_id_allocator.h"
12 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
13 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" 14 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h"
14 #include "platform/graphics/StaticBitmapImage.h" 15 #include "platform/graphics/StaticBitmapImage.h"
15 #include "wtf/Compiler.h" 16 #include "wtf/Compiler.h"
16 #include <memory> 17 #include <memory>
17 18
18 namespace blink { 19 namespace blink {
19 20
20 class PLATFORM_EXPORT OffscreenCanvasFrameDispatcherImpl final 21 class PLATFORM_EXPORT OffscreenCanvasFrameDispatcherImpl final
21 : public OffscreenCanvasFrameDispatcher, 22 : public OffscreenCanvasFrameDispatcher,
22 NON_EXPORTED_BASE( 23 NON_EXPORTED_BASE(
23 public cc::mojom::blink::MojoCompositorFrameSinkClient) { 24 public cc::mojom::blink::MojoCompositorFrameSinkClient) {
24 public: 25 public:
25 OffscreenCanvasFrameDispatcherImpl(uint32_t clientId, 26 OffscreenCanvasFrameDispatcherImpl(uint32_t clientId,
26 uint32_t sinkId, 27 uint32_t sinkId,
27 uint32_t localId,
28 uint64_t nonceHigh,
29 uint64_t nonceLow,
30 int canvasId, 28 int canvasId,
31 int width, 29 int width,
32 int height); 30 int height);
33 31
34 // OffscreenCanvasFrameDispatcher implementation. 32 // OffscreenCanvasFrameDispatcher implementation.
35 ~OffscreenCanvasFrameDispatcherImpl() override {} 33 ~OffscreenCanvasFrameDispatcherImpl() override {}
36 void dispatchFrame(RefPtr<StaticBitmapImage>, 34 void dispatchFrame(RefPtr<StaticBitmapImage>,
37 double commitStartTime, 35 double commitStartTime,
38 bool isWebGLSoftwareRendering = false) override; 36 bool isWebGLSoftwareRendering = false) override;
39 void reclaimResource(unsigned resourceId) override; 37 void reclaimResource(unsigned resourceId) override;
40 38
41 // cc::mojom::blink::MojoCompositorFrameSinkClient implementation. 39 // cc::mojom::blink::MojoCompositorFrameSinkClient implementation.
42 void DidReceiveCompositorFrameAck() override; 40 void DidReceiveCompositorFrameAck() override;
43 void OnBeginFrame(const cc::BeginFrameArgs&) override; 41 void OnBeginFrame(const cc::BeginFrameArgs&) override;
44 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; 42 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
45 void WillDrawSurface() override; 43 void WillDrawSurface() override;
46 44
47 // This enum is used in histogram, so it should be append-only. 45 // This enum is used in histogram, so it should be append-only.
48 enum OffscreenCanvasCommitType { 46 enum OffscreenCanvasCommitType {
49 CommitGPUCanvasGPUCompositing = 0, 47 CommitGPUCanvasGPUCompositing = 0,
50 CommitGPUCanvasSoftwareCompositing = 1, 48 CommitGPUCanvasSoftwareCompositing = 1,
51 CommitSoftwareCanvasGPUCompositing = 2, 49 CommitSoftwareCanvasGPUCompositing = 2,
52 CommitSoftwareCanvasSoftwareCompositing = 3, 50 CommitSoftwareCanvasSoftwareCompositing = 3,
53 OffscreenCanvasCommitTypeCount, 51 OffscreenCanvasCommitTypeCount,
54 }; 52 };
55 53
56 void reshape(int width, int height) override; 54 void reshape(int width, int height) override;
57 55
58 private: 56 private:
57 // Surface-related
58 cc::SurfaceIdAllocator m_surfaceIdAllocator;
59 const cc::FrameSinkId m_frameSinkId; 59 const cc::FrameSinkId m_frameSinkId;
60 cc::LocalFrameId m_currentLocalFrameId; 60 cc::LocalFrameId m_currentLocalFrameId;
61
61 int m_width; 62 int m_width;
62 int m_height; 63 int m_height;
63 64
64 unsigned m_nextResourceId; 65 unsigned m_nextResourceId;
65 HashMap<unsigned, RefPtr<StaticBitmapImage>> m_cachedImages; 66 HashMap<unsigned, RefPtr<StaticBitmapImage>> m_cachedImages;
66 HashMap<unsigned, std::unique_ptr<cc::SharedBitmap>> m_sharedBitmaps; 67 HashMap<unsigned, std::unique_ptr<cc::SharedBitmap>> m_sharedBitmaps;
67 HashMap<unsigned, GLuint> m_cachedTextureIds; 68 HashMap<unsigned, GLuint> m_cachedTextureIds;
68 HashSet<unsigned> m_spareResourceLocks; 69 HashSet<unsigned> m_spareResourceLocks;
69 70
70 bool verifyImageSize(const IntSize); 71 bool verifyImageSize(const IntSize);
71 72
72 cc::mojom::blink::MojoCompositorFrameSinkPtr m_sink; 73 cc::mojom::blink::MojoCompositorFrameSinkPtr m_sink;
73 mojo::Binding<cc::mojom::blink::MojoCompositorFrameSinkClient> m_binding; 74 mojo::Binding<cc::mojom::blink::MojoCompositorFrameSinkClient> m_binding;
74 75
75 int m_placeholderCanvasId; 76 int m_placeholderCanvasId;
76 77
77 void setTransferableResourceToSharedBitmap(cc::TransferableResource&, 78 void setTransferableResourceToSharedBitmap(cc::TransferableResource&,
78 RefPtr<StaticBitmapImage>); 79 RefPtr<StaticBitmapImage>);
79 void setTransferableResourceToSharedGPUContext(cc::TransferableResource&, 80 void setTransferableResourceToSharedGPUContext(cc::TransferableResource&,
80 RefPtr<StaticBitmapImage>); 81 RefPtr<StaticBitmapImage>);
81 void setTransferableResourceToStaticBitmapImage(cc::TransferableResource&, 82 void setTransferableResourceToStaticBitmapImage(cc::TransferableResource&,
82 RefPtr<StaticBitmapImage>); 83 RefPtr<StaticBitmapImage>);
83 }; 84 };
84 85
85 } // namespace blink 86 } // namespace blink
86 87
87 #endif // OffscreenCanvasFrameDispatcherImpl_h 88 #endif // OffscreenCanvasFrameDispatcherImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698