| 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 "cc/layers/solid_color_layer.h" | 9 #include "cc/layers/solid_color_layer.h" |
| 10 #include "cc/layers/surface_layer.h" | 10 #include "cc/layers/surface_layer.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/gfx/geometry/dip_util.h" | 21 #include "ui/gfx/geometry/dip_util.h" |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 void SatisfyCallback(cc::SurfaceManager* manager, | 27 void SatisfyCallback(cc::SurfaceManager* manager, |
| 28 const cc::SurfaceSequence& sequence) { | 28 const cc::SurfaceSequence& sequence) { |
| 29 std::vector<uint32_t> sequences; | 29 std::vector<uint32_t> sequences; |
| 30 sequences.push_back(sequence.sequence); | 30 sequences.push_back(sequence.sequence); |
| 31 manager->DidSatisfySequences(sequence.client_id, &sequences); | 31 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void RequireCallback(cc::SurfaceManager* manager, | 34 void RequireCallback(cc::SurfaceManager* manager, |
| 35 const cc::SurfaceId& id, | 35 const cc::SurfaceId& id, |
| 36 const cc::SurfaceSequence& sequence) { | 36 const cc::SurfaceSequence& sequence) { |
| 37 cc::Surface* surface = manager->GetSurfaceForId(id); | 37 cc::Surface* surface = manager->GetSurfaceForId(id); |
| 38 if (!surface) { | 38 if (!surface) { |
| 39 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 39 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
| 40 return; | 40 return; |
| 41 } | 41 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ReturnResourcesCallback return_resources_callback) | 75 ReturnResourcesCallback return_resources_callback) |
| 76 : view_(view), | 76 : view_(view), |
| 77 return_resources_callback_(return_resources_callback), | 77 return_resources_callback_(return_resources_callback), |
| 78 background_layer_(cc::SolidColorLayer::Create()) { | 78 background_layer_(cc::SolidColorLayer::Create()) { |
| 79 DCHECK(view_); | 79 DCHECK(view_); |
| 80 DCHECK(!return_resources_callback_.is_null()); | 80 DCHECK(!return_resources_callback_.is_null()); |
| 81 | 81 |
| 82 surface_manager_ = | 82 surface_manager_ = |
| 83 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); | 83 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); |
| 84 surface_id_allocator_.reset(new cc::SurfaceIdAllocator( | 84 surface_id_allocator_.reset(new cc::SurfaceIdAllocator( |
| 85 ui::ContextProviderFactory::GetInstance()->AllocateSurfaceClientId())); | 85 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId())); |
| 86 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); | 86 surface_manager_->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id()); |
| 87 | 87 |
| 88 background_layer_->SetBackgroundColor(background_color); | 88 background_layer_->SetBackgroundColor(background_color); |
| 89 view_->GetLayer()->AddChild(background_layer_); | 89 view_->GetLayer()->AddChild(background_layer_); |
| 90 UpdateBackgroundLayer(); | 90 UpdateBackgroundLayer(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() { | 93 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() { |
| 94 DestroyDelegatedContent(); | 94 DestroyDelegatedContent(); |
| 95 surface_factory_.reset(); | 95 surface_factory_.reset(); |
| 96 surface_manager_->InvalidateSurfaceClientId( | 96 surface_manager_->InvalidateFrameSinkId( |
| 97 surface_id_allocator_->client_id()); | 97 surface_id_allocator_->frame_sink_id()); |
| 98 background_layer_->RemoveFromParent(); | 98 background_layer_->RemoveFromParent(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 DelegatedFrameHostAndroid::FrameData::FrameData() = default; | 101 DelegatedFrameHostAndroid::FrameData::FrameData() = default; |
| 102 | 102 |
| 103 DelegatedFrameHostAndroid::FrameData::~FrameData() = default; | 103 DelegatedFrameHostAndroid::FrameData::~FrameData() = default; |
| 104 | 104 |
| 105 void DelegatedFrameHostAndroid::SubmitCompositorFrame( | 105 void DelegatedFrameHostAndroid::SubmitCompositorFrame( |
| 106 cc::CompositorFrame frame, | 106 cc::CompositorFrame frame, |
| 107 cc::SurfaceFactory::DrawCallback draw_callback) { | 107 cc::SurfaceFactory::DrawCallback draw_callback) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 current_frame_->surface_size, | 151 current_frame_->surface_size, |
| 152 !current_frame_->has_transparent_background); | 152 !current_frame_->has_transparent_background); |
| 153 view_->GetLayer()->AddChild(content_layer_); | 153 view_->GetLayer()->AddChild(content_layer_); |
| 154 UpdateBackgroundLayer(); | 154 UpdateBackgroundLayer(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id, | 157 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id, |
| 158 std::move(frame), draw_callback); | 158 std::move(frame), draw_callback); |
| 159 } | 159 } |
| 160 | 160 |
| 161 uint32_t DelegatedFrameHostAndroid::GetSurfaceClientId() const { | 161 cc::FrameSinkId DelegatedFrameHostAndroid::GetFrameSinkId() const { |
| 162 return surface_id_allocator_->client_id(); | 162 return surface_id_allocator_->frame_sink_id(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void DelegatedFrameHostAndroid::RequestCopyOfSurface( | 165 void DelegatedFrameHostAndroid::RequestCopyOfSurface( |
| 166 WindowAndroidCompositor* compositor, | 166 WindowAndroidCompositor* compositor, |
| 167 const gfx::Rect& src_subrect_in_pixel, | 167 const gfx::Rect& src_subrect_in_pixel, |
| 168 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback) { | 168 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback) { |
| 169 DCHECK(current_frame_); | 169 DCHECK(current_frame_); |
| 170 DCHECK(!result_callback.is_null()); | 170 DCHECK(!result_callback.is_null()); |
| 171 | 171 |
| 172 scoped_refptr<cc::Layer> readback_layer = | 172 scoped_refptr<cc::Layer> readback_layer = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 content_size_in_dip.width() < container_size_in_dip_.width() || | 246 content_size_in_dip.width() < container_size_in_dip_.width() || |
| 247 content_size_in_dip.height() < container_size_in_dip_.height(); | 247 content_size_in_dip.height() < container_size_in_dip_.height(); |
| 248 } else { | 248 } else { |
| 249 background_is_drawable = true; | 249 background_is_drawable = true; |
| 250 } | 250 } |
| 251 | 251 |
| 252 background_layer_->SetIsDrawable(background_is_drawable); | 252 background_layer_->SetIsDrawable(background_is_drawable); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace ui | 255 } // namespace ui |
| OLD | NEW |