OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| 6 #define UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "cc/output/copy_output_request.h" |
| 11 #include "cc/resources/returned_resource.h" |
| 12 #include "cc/surfaces/surface_factory.h" |
| 13 #include "cc/surfaces/surface_factory_client.h" |
| 14 #include "ui/android/ui_android_export.h" |
| 15 #include "ui/gfx/selection_bound.h" |
| 16 |
| 17 namespace cc { |
| 18 |
| 19 class CompositorFrame; |
| 20 class CopyOutputResult; |
| 21 class Layer; |
| 22 class SurfaceId; |
| 23 class SurfaceManager; |
| 24 class SurfaceLayer; |
| 25 class SurfaceIdAllocator; |
| 26 enum class SurfaceDrawStatus; |
| 27 |
| 28 } // namespace cc |
| 29 |
| 30 namespace ui { |
| 31 class ViewAndroid; |
| 32 class WindowAndroidCompositor; |
| 33 |
| 34 class UI_ANDROID_EXPORT DelegatedFrameHostAndroid |
| 35 : public cc::SurfaceFactoryClient { |
| 36 public: |
| 37 using ReturnResourcesCallback = |
| 38 base::Callback<void(const cc::ReturnedResourceArray&)>; |
| 39 |
| 40 DelegatedFrameHostAndroid(ViewAndroid* view, |
| 41 SkColor background_color, |
| 42 ReturnResourcesCallback return_resources_callback); |
| 43 |
| 44 ~DelegatedFrameHostAndroid() override; |
| 45 |
| 46 void SubmitCompositorFrame(cc::CompositorFrame frame, |
| 47 cc::SurfaceFactory::DrawCallback draw_callback); |
| 48 |
| 49 void DestroyDelegatedContent(); |
| 50 |
| 51 bool HasDelegatedContent() const; |
| 52 |
| 53 uint32_t GetSurfaceClientId() const; |
| 54 |
| 55 // Should only be called when the host has a content layer. |
| 56 void RequestCopyOfSurface( |
| 57 WindowAndroidCompositor* compositor, |
| 58 const gfx::Rect& src_subrect_in_pixel, |
| 59 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback); |
| 60 |
| 61 void OutputSurfaceChanged(); |
| 62 |
| 63 void UpdateBackgroundColor(SkColor color); |
| 64 |
| 65 void SetContentsOpaque(bool opaque); |
| 66 |
| 67 void UpdateContainerSizeinDIP(const gfx::Size& size_in_dip); |
| 68 |
| 69 private: |
| 70 // cc::SurfaceFactoryClient implementation. |
| 71 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 72 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 73 |
| 74 void UpdateBackgroundLayer(); |
| 75 |
| 76 ViewAndroid* view_; |
| 77 |
| 78 cc::SurfaceManager* surface_manager_; |
| 79 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 80 ReturnResourcesCallback return_resources_callback_; |
| 81 |
| 82 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 83 |
| 84 struct FrameData { |
| 85 FrameData(); |
| 86 ~FrameData(); |
| 87 |
| 88 cc::SurfaceId surface_id; |
| 89 gfx::Size surface_size; |
| 90 gfx::Vector2dF location_bar_content_translation; |
| 91 cc::Selection<gfx::SelectionBound> viewport_selection; |
| 92 }; |
| 93 std::unique_ptr<FrameData> current_frame_; |
| 94 |
| 95 scoped_refptr<cc::SurfaceLayer> content_layer_; |
| 96 |
| 97 scoped_refptr<cc::Layer> background_layer_; |
| 98 |
| 99 gfx::Size container_size_in_dip_; |
| 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameHostAndroid); |
| 102 }; |
| 103 |
| 104 } // namespace ui |
| 105 |
| 106 #endif // UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
OLD | NEW |