| 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 UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ | 5 #ifndef UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| 6 #define UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ | 6 #define UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| 11 #include "cc/resources/returned_resource.h" | 11 #include "cc/resources/returned_resource.h" |
| 12 #include "cc/surfaces/surface_factory.h" | 12 #include "cc/surfaces/surface_factory.h" |
| 13 #include "cc/surfaces/surface_factory_client.h" | 13 #include "cc/surfaces/surface_factory_client.h" |
| 14 #include "ui/android/ui_android_export.h" | 14 #include "ui/android/ui_android_export.h" |
| 15 #include "ui/gfx/selection_bound.h" | 15 #include "ui/gfx/selection_bound.h" |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 class CompositorFrame; | 19 class CompositorFrame; |
| 20 class Layer; | |
| 21 class SurfaceManager; | 20 class SurfaceManager; |
| 22 class SurfaceLayer; | 21 class SurfaceLayer; |
| 23 class LocalSurfaceIdAllocator; | 22 class LocalSurfaceIdAllocator; |
| 24 enum class SurfaceDrawStatus; | 23 enum class SurfaceDrawStatus; |
| 25 | 24 |
| 26 } // namespace cc | 25 } // namespace cc |
| 27 | 26 |
| 28 namespace ui { | 27 namespace ui { |
| 29 class ViewAndroid; | 28 class ViewAndroid; |
| 30 class WindowAndroidCompositor; | 29 class WindowAndroidCompositor; |
| 31 | 30 |
| 32 class UI_ANDROID_EXPORT DelegatedFrameHostAndroid | 31 class UI_ANDROID_EXPORT DelegatedFrameHostAndroid |
| 33 : public cc::SurfaceFactoryClient { | 32 : public cc::SurfaceFactoryClient { |
| 34 public: | 33 public: |
| 35 class Client { | 34 class Client { |
| 36 public: | 35 public: |
| 37 virtual void SetBeginFrameSource( | 36 virtual void SetBeginFrameSource( |
| 38 cc::BeginFrameSource* begin_frame_source) = 0; | 37 cc::BeginFrameSource* begin_frame_source) = 0; |
| 39 virtual void ReturnResources(const cc::ReturnedResourceArray&) = 0; | 38 virtual void ReturnResources(const cc::ReturnedResourceArray&) = 0; |
| 40 }; | 39 }; |
| 41 | 40 |
| 42 DelegatedFrameHostAndroid(ViewAndroid* view, | 41 DelegatedFrameHostAndroid(ViewAndroid* view, |
| 43 SkColor background_color, | |
| 44 Client* client, | 42 Client* client, |
| 45 const cc::FrameSinkId& frame_sink_id); | 43 const cc::FrameSinkId& frame_sink_id); |
| 46 | 44 |
| 47 ~DelegatedFrameHostAndroid() override; | 45 ~DelegatedFrameHostAndroid() override; |
| 48 | 46 |
| 49 void SubmitCompositorFrame(cc::CompositorFrame frame, | 47 void SubmitCompositorFrame(cc::CompositorFrame frame, |
| 50 cc::SurfaceFactory::DrawCallback draw_callback); | 48 cc::SurfaceFactory::DrawCallback draw_callback); |
| 51 | 49 |
| 52 void DestroyDelegatedContent(); | 50 void DestroyDelegatedContent(); |
| 53 | 51 |
| 54 bool HasDelegatedContent() const; | 52 bool HasDelegatedContent() const; |
| 55 | 53 |
| 56 cc::FrameSinkId GetFrameSinkId() const; | 54 cc::FrameSinkId GetFrameSinkId() const; |
| 57 | 55 |
| 58 // Should only be called when the host has a content layer. | 56 // Should only be called when the host has a content layer. |
| 59 void RequestCopyOfSurface( | 57 void RequestCopyOfSurface( |
| 60 WindowAndroidCompositor* compositor, | 58 WindowAndroidCompositor* compositor, |
| 61 const gfx::Rect& src_subrect_in_pixel, | 59 const gfx::Rect& src_subrect_in_pixel, |
| 62 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback); | 60 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback); |
| 63 | 61 |
| 64 void CompositorFrameSinkChanged(); | 62 void CompositorFrameSinkChanged(); |
| 65 | 63 |
| 66 void UpdateBackgroundColor(SkColor color); | |
| 67 | |
| 68 void UpdateContainerSizeinDIP(const gfx::Size& size_in_dip); | |
| 69 | |
| 70 // Called when this DFH is attached/detached from a parent browser compositor | 64 // Called when this DFH is attached/detached from a parent browser compositor |
| 71 // and needs to be attached to the surface hierarchy. | 65 // and needs to be attached to the surface hierarchy. |
| 72 void AttachToCompositor(WindowAndroidCompositor* compositor); | 66 void AttachToCompositor(WindowAndroidCompositor* compositor); |
| 73 void DetachFromCompositor(); | 67 void DetachFromCompositor(); |
| 74 | 68 |
| 75 private: | 69 private: |
| 76 // cc::SurfaceFactoryClient implementation. | 70 // cc::SurfaceFactoryClient implementation. |
| 77 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 71 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 78 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 72 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 79 | 73 |
| 80 void UpdateBackgroundLayer(); | |
| 81 | |
| 82 const cc::FrameSinkId frame_sink_id_; | 74 const cc::FrameSinkId frame_sink_id_; |
| 83 | 75 |
| 84 ViewAndroid* view_; | 76 ViewAndroid* view_; |
| 85 | 77 |
| 86 cc::SurfaceManager* surface_manager_; | 78 cc::SurfaceManager* surface_manager_; |
| 87 std::unique_ptr<cc::LocalSurfaceIdAllocator> local_surface_id_allocator_; | 79 std::unique_ptr<cc::LocalSurfaceIdAllocator> local_surface_id_allocator_; |
| 88 WindowAndroidCompositor* registered_parent_compositor_ = nullptr; | 80 WindowAndroidCompositor* registered_parent_compositor_ = nullptr; |
| 89 Client* client_; | 81 Client* client_; |
| 90 | 82 |
| 91 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 83 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 92 | 84 |
| 93 struct FrameData { | 85 struct FrameData { |
| 94 FrameData(); | 86 FrameData(); |
| 95 ~FrameData(); | 87 ~FrameData(); |
| 96 | 88 |
| 97 cc::LocalSurfaceId local_surface_id; | 89 cc::LocalSurfaceId local_surface_id; |
| 98 gfx::Size surface_size; | 90 gfx::Size surface_size; |
| 99 float top_controls_height; | 91 float top_controls_height; |
| 100 float top_controls_shown_ratio; | 92 float top_controls_shown_ratio; |
| 101 float bottom_controls_height; | 93 float bottom_controls_height; |
| 102 float bottom_controls_shown_ratio; | 94 float bottom_controls_shown_ratio; |
| 103 cc::Selection<gfx::SelectionBound> viewport_selection; | 95 cc::Selection<gfx::SelectionBound> viewport_selection; |
| 104 bool has_transparent_background; | 96 bool has_transparent_background; |
| 105 }; | 97 }; |
| 106 std::unique_ptr<FrameData> current_frame_; | 98 std::unique_ptr<FrameData> current_frame_; |
| 107 | 99 |
| 108 scoped_refptr<cc::SurfaceLayer> content_layer_; | 100 scoped_refptr<cc::SurfaceLayer> content_layer_; |
| 109 | 101 |
| 110 scoped_refptr<cc::Layer> background_layer_; | |
| 111 | |
| 112 gfx::Size container_size_in_dip_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameHostAndroid); | 102 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameHostAndroid); |
| 115 }; | 103 }; |
| 116 | 104 |
| 117 } // namespace ui | 105 } // namespace ui |
| 118 | 106 |
| 119 #endif // UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ | 107 #endif // UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| OLD | NEW |