OLD | NEW |
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 "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
13 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" | 13 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" |
14 #include "platform/graphics/StaticBitmapImage.h" | 14 #include "platform/graphics/StaticBitmapImage.h" |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class PLATFORM_EXPORT OffscreenCanvasFrameDispatcherImpl final | 19 class PLATFORM_EXPORT OffscreenCanvasFrameDispatcherImpl final |
20 : public OffscreenCanvasFrameDispatcher, | 20 : public OffscreenCanvasFrameDispatcher, |
21 WTF_NON_EXPORTED_BASE( | 21 WTF_NON_EXPORTED_BASE( |
22 public cc::mojom::blink::MojoCompositorFrameSinkClient) { | 22 public cc::mojom::blink::MojoCompositorFrameSinkClient) { |
23 public: | 23 public: |
24 OffscreenCanvasFrameDispatcherImpl(uint32_t clientId, | 24 OffscreenCanvasFrameDispatcherImpl(uint32_t clientId, |
25 uint32_t sinkId, | 25 uint32_t sinkId, |
26 uint32_t localId, | 26 uint32_t localId, |
27 uint64_t nonce, | 27 uint64_t nonce, |
| 28 int canvasId, |
28 int width, | 29 int width, |
29 int height); | 30 int height); |
30 | 31 |
31 // OffscreenCanvasFrameDispatcher implementation. | 32 // OffscreenCanvasFrameDispatcher implementation. |
32 ~OffscreenCanvasFrameDispatcherImpl() override {} | 33 ~OffscreenCanvasFrameDispatcherImpl() override {} |
33 void dispatchFrame(RefPtr<StaticBitmapImage>, | 34 void dispatchFrame(RefPtr<StaticBitmapImage>, |
34 double commitStartTime, | 35 double commitStartTime, |
35 bool isWebGLSoftwareRendering = false) override; | 36 bool isWebGLSoftwareRendering = false) override; |
| 37 void reclaimResource(unsigned resourceId) override; |
36 | 38 |
37 // cc::mojom::blink::MojoCompositorFrameSinkClient implementation. | 39 // cc::mojom::blink::MojoCompositorFrameSinkClient implementation. |
38 void DidReceiveCompositorFrameAck() override; | 40 void DidReceiveCompositorFrameAck() override; |
39 void OnBeginFrame(const cc::BeginFrameArgs&) override; | 41 void OnBeginFrame(const cc::BeginFrameArgs&) override; |
40 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; | 42 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
41 | 43 |
42 // This enum is used in histogram, so it should be append-only. | 44 // This enum is used in histogram, so it should be append-only. |
43 enum OffscreenCanvasCommitType { | 45 enum OffscreenCanvasCommitType { |
44 CommitGPUCanvasGPUCompositing = 0, | 46 CommitGPUCanvasGPUCompositing = 0, |
45 CommitGPUCanvasSoftwareCompositing = 1, | 47 CommitGPUCanvasSoftwareCompositing = 1, |
46 CommitSoftwareCanvasGPUCompositing = 2, | 48 CommitSoftwareCanvasGPUCompositing = 2, |
47 CommitSoftwareCanvasSoftwareCompositing = 3, | 49 CommitSoftwareCanvasSoftwareCompositing = 3, |
48 OffscreenCanvasCommitTypeCount, | 50 OffscreenCanvasCommitTypeCount, |
49 }; | 51 }; |
50 | 52 |
51 private: | 53 private: |
52 const cc::SurfaceId m_surfaceId; | 54 const cc::SurfaceId m_surfaceId; |
53 const int m_width; | 55 const int m_width; |
54 const int m_height; | 56 const int m_height; |
55 | 57 |
56 unsigned m_nextResourceId; | 58 unsigned m_nextResourceId; |
57 HashMap<unsigned, RefPtr<StaticBitmapImage>> m_cachedImages; | 59 HashMap<unsigned, RefPtr<StaticBitmapImage>> m_cachedImages; |
58 HashMap<unsigned, std::unique_ptr<cc::SharedBitmap>> m_sharedBitmaps; | 60 HashMap<unsigned, std::unique_ptr<cc::SharedBitmap>> m_sharedBitmaps; |
59 HashMap<unsigned, GLuint> m_cachedTextureIds; | 61 HashMap<unsigned, GLuint> m_cachedTextureIds; |
| 62 HashSet<unsigned> m_spareResourceLocks; |
60 | 63 |
61 bool verifyImageSize(const IntSize); | 64 bool verifyImageSize(const IntSize); |
62 | 65 |
63 cc::mojom::blink::MojoCompositorFrameSinkPtr m_sink; | 66 cc::mojom::blink::MojoCompositorFrameSinkPtr m_sink; |
64 mojo::Binding<cc::mojom::blink::MojoCompositorFrameSinkClient> m_binding; | 67 mojo::Binding<cc::mojom::blink::MojoCompositorFrameSinkClient> m_binding; |
65 | 68 |
| 69 int m_placeholderCanvasId; |
| 70 |
66 void setTransferableResourceToSharedBitmap(cc::TransferableResource&, | 71 void setTransferableResourceToSharedBitmap(cc::TransferableResource&, |
67 RefPtr<StaticBitmapImage>); | 72 RefPtr<StaticBitmapImage>); |
68 void setTransferableResourceToSharedGPUContext(cc::TransferableResource&, | 73 void setTransferableResourceToSharedGPUContext(cc::TransferableResource&, |
69 RefPtr<StaticBitmapImage>); | 74 RefPtr<StaticBitmapImage>); |
70 void setTransferableResourceToStaticBitmapImage(cc::TransferableResource&, | 75 void setTransferableResourceToStaticBitmapImage(cc::TransferableResource&, |
71 RefPtr<StaticBitmapImage>); | 76 RefPtr<StaticBitmapImage>); |
72 }; | 77 }; |
73 | 78 |
74 } // namespace blink | 79 } // namespace blink |
75 | 80 |
76 #endif // OffscreenCanvasFrameDispatcherImpl_h | 81 #endif // OffscreenCanvasFrameDispatcherImpl_h |
OLD | NEW |