Chromium Code Reviews| 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 #include "ui/android/delegated_frame_host_android.h" | 5 #include "ui/android/delegated_frame_host_android.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
| 11 #include "cc/layers/surface_layer.h" | 11 #include "cc/layers/surface_layer.h" |
| 12 #include "cc/output/compositor_frame.h" | 12 #include "cc/output/compositor_frame.h" |
| 13 #include "cc/output/copy_output_result.h" | 13 #include "cc/output/copy_output_result.h" |
| 14 #include "cc/surfaces/local_surface_id_allocator.h" | |
| 15 #include "cc/surfaces/surface.h" | 14 #include "cc/surfaces/surface.h" |
| 16 #include "cc/surfaces/surface_id.h" | 15 #include "cc/surfaces/surface_id.h" |
| 17 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
| 18 #include "ui/android/view_android.h" | 17 #include "ui/android/view_android.h" |
| 19 #include "ui/android/window_android_compositor.h" | 18 #include "ui/android/window_android_compositor.h" |
| 20 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
| 21 #include "ui/display/screen.h" | 20 #include "ui/display/screen.h" |
| 22 #include "ui/gfx/geometry/dip_util.h" | 21 #include "ui/gfx/geometry/dip_util.h" |
| 23 | 22 |
| 24 namespace ui { | 23 namespace ui { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 Client* client, | 55 Client* client, |
| 57 const cc::FrameSinkId& frame_sink_id) | 56 const cc::FrameSinkId& frame_sink_id) |
| 58 : frame_sink_id_(frame_sink_id), | 57 : frame_sink_id_(frame_sink_id), |
| 59 view_(view), | 58 view_(view), |
| 60 surface_manager_(surface_manager), | 59 surface_manager_(surface_manager), |
| 61 client_(client), | 60 client_(client), |
| 62 begin_frame_source_(this) { | 61 begin_frame_source_(this) { |
| 63 DCHECK(view_); | 62 DCHECK(view_); |
| 64 DCHECK(client_); | 63 DCHECK(client_); |
| 65 | 64 |
| 66 local_surface_id_allocator_.reset(new cc::LocalSurfaceIdAllocator()); | |
| 67 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 65 surface_manager_->RegisterFrameSinkId(frame_sink_id_); |
| 68 CreateNewCompositorFrameSinkSupport(); | 66 CreateNewCompositorFrameSinkSupport(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() { | 69 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() { |
| 72 DestroyDelegatedContent(); | 70 DestroyDelegatedContent(); |
| 73 DetachFromCompositor(); | 71 DetachFromCompositor(); |
| 74 support_.reset(); | 72 support_.reset(); |
| 75 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 73 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
| 76 } | 74 } |
| 77 | 75 |
| 78 DelegatedFrameHostAndroid::FrameData::FrameData() = default; | 76 DelegatedFrameHostAndroid::FrameData::FrameData() = default; |
| 79 | 77 |
| 80 DelegatedFrameHostAndroid::FrameData::~FrameData() = default; | 78 DelegatedFrameHostAndroid::FrameData::~FrameData() = default; |
| 81 | 79 |
| 82 void DelegatedFrameHostAndroid::SubmitCompositorFrame( | 80 void DelegatedFrameHostAndroid::SubmitCompositorFrame( |
| 81 cc::LocalSurfaceId local_surface_id, | |
|
Fady Samuel
2017/03/15 12:05:48
const cc::LocalSurfaceId&
Saman Sami
2017/03/16 18:33:08
Done.
| |
| 83 cc::CompositorFrame frame) { | 82 cc::CompositorFrame frame) { |
| 84 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); | 83 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
| 85 gfx::Size surface_size = root_pass->output_rect.size(); | 84 gfx::Size surface_size = root_pass->output_rect.size(); |
| 86 | 85 |
| 87 if (!current_frame_ || surface_size != current_frame_->surface_size || | 86 if (!current_frame_ || surface_size != current_frame_->surface_size || |
|
Fady Samuel
2017/03/15 12:05:48
This can be simplified once you move the condition
Saman Sami
2017/03/16 18:33:08
Done.
| |
| 87 current_frame_->local_surface_id != local_surface_id || | |
| 88 current_frame_->top_controls_height != | 88 current_frame_->top_controls_height != |
| 89 frame.metadata.top_controls_height || | 89 frame.metadata.top_controls_height || |
| 90 current_frame_->top_controls_shown_ratio != | 90 current_frame_->top_controls_shown_ratio != |
| 91 frame.metadata.top_controls_shown_ratio || | 91 frame.metadata.top_controls_shown_ratio || |
| 92 current_frame_->bottom_controls_height != | 92 current_frame_->bottom_controls_height != |
| 93 frame.metadata.bottom_controls_height || | 93 frame.metadata.bottom_controls_height || |
| 94 current_frame_->bottom_controls_shown_ratio != | 94 current_frame_->bottom_controls_shown_ratio != |
| 95 frame.metadata.bottom_controls_shown_ratio || | 95 frame.metadata.bottom_controls_shown_ratio || |
| 96 current_frame_->viewport_selection != frame.metadata.selection || | 96 current_frame_->viewport_selection != frame.metadata.selection || |
| 97 current_frame_->has_transparent_background != | 97 current_frame_->has_transparent_background != |
| 98 root_pass->has_transparent_background) { | 98 root_pass->has_transparent_background) { |
| 99 DestroyDelegatedContent(); | 99 DestroyDelegatedContent(); |
| 100 DCHECK(!content_layer_); | 100 DCHECK(!content_layer_); |
| 101 DCHECK(!current_frame_); | 101 DCHECK(!current_frame_); |
| 102 | 102 |
| 103 current_frame_ = base::MakeUnique<FrameData>(); | 103 current_frame_ = base::MakeUnique<FrameData>(); |
| 104 current_frame_->local_surface_id = | 104 current_frame_->local_surface_id = local_surface_id; |
| 105 local_surface_id_allocator_->GenerateId(); | |
| 106 current_frame_->surface_size = surface_size; | 105 current_frame_->surface_size = surface_size; |
| 107 current_frame_->top_controls_height = frame.metadata.top_controls_height; | 106 current_frame_->top_controls_height = frame.metadata.top_controls_height; |
| 108 current_frame_->top_controls_shown_ratio = | 107 current_frame_->top_controls_shown_ratio = |
| 109 frame.metadata.top_controls_shown_ratio; | 108 frame.metadata.top_controls_shown_ratio; |
| 110 current_frame_->bottom_controls_height = | 109 current_frame_->bottom_controls_height = |
| 111 frame.metadata.bottom_controls_height; | 110 frame.metadata.bottom_controls_height; |
| 112 current_frame_->bottom_controls_shown_ratio = | 111 current_frame_->bottom_controls_shown_ratio = |
| 113 frame.metadata.bottom_controls_shown_ratio; | 112 frame.metadata.bottom_controls_shown_ratio; |
| 114 current_frame_->has_transparent_background = | 113 current_frame_->has_transparent_background = |
| 115 root_pass->has_transparent_background; | 114 root_pass->has_transparent_background; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 this, surface_manager_, frame_sink_id_, false /* is_root */, | 224 this, surface_manager_, frame_sink_id_, false /* is_root */, |
| 226 false /* handles_frame_sink_id_invalidation */, | 225 false /* handles_frame_sink_id_invalidation */, |
| 227 true /* needs_sync_points */); | 226 true /* needs_sync_points */); |
| 228 } | 227 } |
| 229 | 228 |
| 230 cc::SurfaceId DelegatedFrameHostAndroid::SurfaceId() const { | 229 cc::SurfaceId DelegatedFrameHostAndroid::SurfaceId() const { |
| 231 return cc::SurfaceId(frame_sink_id_, current_frame_->local_surface_id); | 230 return cc::SurfaceId(frame_sink_id_, current_frame_->local_surface_id); |
| 232 } | 231 } |
| 233 | 232 |
| 234 } // namespace ui | 233 } // namespace ui |
| OLD | NEW |