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