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 ANDROID_WEBVIEW_BROWSER_COMPOSITOR_FRAME_CONSUMER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_COMPOSITOR_FRAME_CONSUMER_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_COMPOSITOR_FRAME_CONSUMER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_COMPOSITOR_FRAME_CONSUMER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
| 10 #include "android_webview/browser/compositor_id.h" |
10 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 11 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
11 #include "cc/resources/returned_resource.h" | 12 #include "cc/resources/returned_resource.h" |
12 #include "ui/gfx/geometry/vector2d.h" | 13 #include "ui/gfx/geometry/vector2d.h" |
13 | 14 |
14 namespace android_webview { | 15 namespace android_webview { |
15 | 16 |
16 class ChildFrame; | 17 class ChildFrame; |
17 class CompositorFrameProducer; | 18 class CompositorFrameProducer; |
18 | 19 |
19 class CompositorFrameConsumer { | 20 class CompositorFrameConsumer { |
20 public: | 21 public: |
21 struct ReturnedResources { | 22 struct ReturnedResources { |
22 ReturnedResources(); | 23 ReturnedResources(); |
23 ~ReturnedResources(); | 24 ~ReturnedResources(); |
24 | 25 |
25 uint32_t output_surface_id; | 26 uint32_t output_surface_id; |
26 cc::ReturnedResourceArray resources; | 27 cc::ReturnedResourceArray resources; |
27 }; | 28 }; |
28 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; | 29 using ReturnedResourcesMap = |
| 30 std::map<CompositorID, ReturnedResources, CompositorIDComparator>; |
29 | 31 |
30 // A CompositorFrameConsumer may be registered with at most one | 32 // A CompositorFrameConsumer may be registered with at most one |
31 // CompositorFrameProducer. | 33 // CompositorFrameProducer. |
32 // The producer is responsible for managing the relationship with its | 34 // The producer is responsible for managing the relationship with its |
33 // consumers. The only exception to this is when a consumer is explicitly | 35 // consumers. The only exception to this is when a consumer is explicitly |
34 // destroyed, at which point it needs to inform its producer. | 36 // destroyed, at which point it needs to inform its producer. |
35 // In order to register a consumer with a new producer, the current producer | 37 // In order to register a consumer with a new producer, the current producer |
36 // must unregister the consumer, and call SetCompositorProducer(nullptr). | 38 // must unregister the consumer, and call SetCompositorProducer(nullptr). |
37 virtual void SetCompositorFrameProducer( | 39 virtual void SetCompositorFrameProducer( |
38 CompositorFrameProducer* compositor_frame_producer) = 0; | 40 CompositorFrameProducer* compositor_frame_producer) = 0; |
39 virtual void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset) = 0; | 41 virtual void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset) = 0; |
40 virtual void SetFrameOnUI(std::unique_ptr<ChildFrame> frame) = 0; | 42 virtual void SetFrameOnUI(std::unique_ptr<ChildFrame> frame) = 0; |
41 virtual void InitializeHardwareDrawIfNeededOnUI() = 0; | 43 virtual void InitializeHardwareDrawIfNeededOnUI() = 0; |
42 virtual ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() | 44 virtual ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() |
43 const = 0; | 45 const = 0; |
44 virtual void SwapReturnedResourcesOnUI( | 46 virtual void SwapReturnedResourcesOnUI( |
45 ReturnedResourcesMap* returned_resource_map) = 0; | 47 ReturnedResourcesMap* returned_resource_map) = 0; |
46 virtual bool ReturnedResourcesEmptyOnUI() const = 0; | 48 virtual bool ReturnedResourcesEmptyOnUI() const = 0; |
47 virtual std::unique_ptr<ChildFrame> PassUncommittedFrameOnUI() = 0; | 49 virtual std::unique_ptr<ChildFrame> PassUncommittedFrameOnUI() = 0; |
48 virtual bool HasFrameOnUI() const = 0; | 50 virtual bool HasFrameOnUI() const = 0; |
49 virtual void DeleteHardwareRendererOnUI() = 0; | 51 virtual void DeleteHardwareRendererOnUI() = 0; |
50 | 52 |
51 protected: | 53 protected: |
52 virtual ~CompositorFrameConsumer() {} | 54 virtual ~CompositorFrameConsumer() {} |
53 }; | 55 }; |
54 | 56 |
55 } // namespace android_webview | 57 } // namespace android_webview |
56 | 58 |
57 #endif // ANDROID_WEBVIEW_BROWSER_COMPOSITOR_FRAME_PRODUCER_H_ | 59 #endif // ANDROID_WEBVIEW_BROWSER_COMPOSITOR_FRAME_PRODUCER_H_ |
OLD | NEW |