Index: content/browser/compositor/delegated_frame_surface_host.cc |
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_surface_host.cc |
similarity index 75% |
copy from content/browser/compositor/delegated_frame_host.cc |
copy to content/browser/compositor/delegated_frame_surface_host.cc |
index 91c8e035ceefcbef7fe1d401eaf64c2764a0cba0..f61e84250a30b29885a8d6ab25b65f507f8c7f55 100644 |
--- a/content/browser/compositor/delegated_frame_host.cc |
+++ b/content/browser/compositor/delegated_frame_surface_host.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/compositor/delegated_frame_host.h" |
+#include "content/browser/compositor/delegated_frame_surface_host.h" |
#include "base/callback_helpers.h" |
#include "base/command_line.h" |
@@ -11,6 +11,7 @@ |
#include "cc/output/copy_output_request.h" |
#include "cc/resources/single_release_callback.h" |
#include "cc/resources/texture_mailbox.h" |
+#include "cc/surfaces/surface_factory.h" |
#include "content/browser/compositor/resize_lock.h" |
#include "content/common/gpu/client/gl_helper.h" |
#include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
@@ -22,31 +23,10 @@ |
namespace content { |
//////////////////////////////////////////////////////////////////////////////// |
-// DelegatedFrameHostClient |
- |
-bool DelegatedFrameHostClient::ShouldCreateResizeLock() { |
- // On Windows and Linux, holding pointer moves will not help throttling |
- // resizes. |
- // TODO(piman): on Windows we need to block (nested message loop?) the |
- // WM_SIZE event. On Linux we need to throttle at the WM level using |
- // _NET_WM_SYNC_REQUEST. |
- // TODO(ccameron): Mac browser window resizing is incompletely implemented. |
-#if !defined(OS_CHROMEOS) |
- return false; |
-#else |
- return GetDelegatedFrameHost()->ShouldCreateResizeLock(); |
-#endif |
-} |
- |
-void DelegatedFrameHostClient::RequestCopyOfOutput( |
- scoped_ptr<cc::CopyOutputRequest> request) { |
- GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); |
-} |
- |
-//////////////////////////////////////////////////////////////////////////////// |
-// DelegatedFrameHost |
+// DelegatedFrameSurfaceHost |
-DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
+DelegatedFrameSurfaceHost::DelegatedFrameSurfaceHost( |
+ DelegatedFrameHostClient* client) |
: client_(client), |
last_output_surface_id_(0), |
pending_delegated_ack_count_(0), |
@@ -56,7 +36,7 @@ DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
ImageTransportFactory::GetInstance()->AddObserver(this); |
} |
-void DelegatedFrameHost::WasShown() { |
+void DelegatedFrameSurfaceHost::WasShown() { |
delegated_frame_evictor_->SetVisible(true); |
if (!released_front_lock_.get()) { |
@@ -66,12 +46,12 @@ void DelegatedFrameHost::WasShown() { |
} |
} |
-void DelegatedFrameHost::WasHidden() { |
+void DelegatedFrameSurfaceHost::WasHidden() { |
delegated_frame_evictor_->SetVisible(false); |
released_front_lock_ = NULL; |
} |
-void DelegatedFrameHost::MaybeCreateResizeLock() { |
+void DelegatedFrameSurfaceHost::MaybeCreateResizeLock() { |
if (!client_->ShouldCreateResizeLock()) |
return; |
DCHECK(client_->GetCompositor()); |
@@ -91,7 +71,7 @@ void DelegatedFrameHost::MaybeCreateResizeLock() { |
resize_lock_ = client_->CreateResizeLock(defer_compositor_lock); |
} |
-bool DelegatedFrameHost::ShouldCreateResizeLock() { |
+bool DelegatedFrameSurfaceHost::ShouldCreateResizeLock() { |
RenderWidgetHostImpl* host = client_->GetHost(); |
if (resize_lock_) |
@@ -111,12 +91,12 @@ bool DelegatedFrameHost::ShouldCreateResizeLock() { |
return true; |
} |
-void DelegatedFrameHost::RequestCopyOfOutput( |
+void DelegatedFrameSurfaceHost::RequestCopyOfOutput( |
scoped_ptr<cc::CopyOutputRequest> request) { |
client_->GetLayer()->RequestCopyOfOutput(request.Pass()); |
} |
-void DelegatedFrameHost::CopyFromCompositingSurface( |
+void DelegatedFrameSurfaceHost::CopyFromCompositingSurface( |
const gfx::Rect& src_subrect, |
const gfx::Size& dst_size, |
const base::Callback<void(bool, const SkBitmap&)>& callback, |
@@ -134,7 +114,7 @@ void DelegatedFrameHost::CopyFromCompositingSurface( |
client_->ConvertViewSizeToPixel(dst_size); |
scoped_ptr<cc::CopyOutputRequest> request = |
cc::CopyOutputRequest::CreateRequest(base::Bind( |
- &DelegatedFrameHost::CopyFromCompositingSurfaceHasResult, |
+ &DelegatedFrameSurfaceHost::CopyFromCompositingSurfaceHasResult, |
dst_size_in_pixel, |
color_type, |
callback)); |
@@ -144,10 +124,10 @@ void DelegatedFrameHost::CopyFromCompositingSurface( |
client_->RequestCopyOfOutput(request.Pass()); |
} |
-void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( |
- const gfx::Rect& src_subrect, |
- const scoped_refptr<media::VideoFrame>& target, |
- const base::Callback<void(bool)>& callback) { |
+void DelegatedFrameSurfaceHost::CopyFromCompositingSurfaceToVideoFrame( |
+ const gfx::Rect& src_subrect, |
+ const scoped_refptr<media::VideoFrame>& target, |
+ const base::Callback<void(bool)>& callback) { |
if (!CanCopyToVideoFrame()) { |
callback.Run(false); |
return; |
@@ -167,8 +147,8 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( |
scoped_ptr<cc::CopyOutputRequest> request = |
cc::CopyOutputRequest::CreateRequest(base::Bind( |
- &DelegatedFrameHost:: |
- CopyFromCompositingSurfaceHasResultForVideo, |
+ &DelegatedFrameSurfaceHost:: |
+ CopyFromCompositingSurfaceHasResultForVideo, |
AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. |
subscriber_texture, |
target, |
@@ -185,54 +165,57 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( |
client_->RequestCopyOfOutput(request.Pass()); |
} |
-bool DelegatedFrameHost::CanCopyToBitmap() const { |
+bool DelegatedFrameSurfaceHost::CanCopyToBitmap() const { |
return client_->GetCompositor() && |
client_->GetLayer()->has_external_content(); |
} |
-bool DelegatedFrameHost::CanCopyToVideoFrame() const { |
+bool DelegatedFrameSurfaceHost::CanCopyToVideoFrame() const { |
return client_->GetCompositor() && |
client_->GetLayer()->has_external_content(); |
} |
-bool DelegatedFrameHost::CanSubscribeFrame() const { |
+bool DelegatedFrameSurfaceHost::CanSubscribeFrame() const { |
return true; |
} |
-void DelegatedFrameHost::BeginFrameSubscription( |
+void DelegatedFrameSurfaceHost::BeginFrameSubscription( |
scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
frame_subscriber_ = subscriber.Pass(); |
} |
-void DelegatedFrameHost::EndFrameSubscription() { |
+void DelegatedFrameSurfaceHost::EndFrameSubscription() { |
idle_frame_subscriber_textures_.clear(); |
frame_subscriber_.reset(); |
} |
-bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { |
+bool DelegatedFrameSurfaceHost::HasFrameSubscriber() const { |
+ return frame_subscriber_; |
+} |
+ |
+bool DelegatedFrameSurfaceHost::ShouldSkipFrame(gfx::Size size_in_dip) const { |
// Should skip a frame only when another frame from the renderer is guaranteed |
// to replace it. Otherwise may cause hangs when the renderer is waiting for |
// the completion of latency infos (such as when taking a Snapshot.) |
if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
- can_lock_compositor_ == NO_PENDING_COMMIT || |
- !resize_lock_.get()) |
+ can_lock_compositor_ == NO_PENDING_COMMIT || !resize_lock_.get()) |
return false; |
return size_in_dip != resize_lock_->expected_size(); |
} |
-void DelegatedFrameHost::WasResized() { |
+void DelegatedFrameSurfaceHost::WasResized() { |
MaybeCreateResizeLock(); |
} |
-gfx::Size DelegatedFrameHost::GetRequestedRendererSize() const { |
+gfx::Size DelegatedFrameSurfaceHost::GetRequestedRendererSize() const { |
if (resize_lock_) |
return resize_lock_->expected_size(); |
else |
return client_->DesiredFrameSize(); |
} |
-void DelegatedFrameHost::CheckResizeLock() { |
+void DelegatedFrameSurfaceHost::CheckResizeLock() { |
if (!resize_lock_ || |
resize_lock_->expected_size() != current_frame_size_in_dip_) |
return; |
@@ -248,13 +231,13 @@ void DelegatedFrameHost::CheckResizeLock() { |
} |
} |
-void DelegatedFrameHost::DidReceiveFrameFromRenderer() { |
+void DelegatedFrameSurfaceHost::DidReceiveFrameFromRenderer() { |
if (frame_subscriber() && CanCopyToVideoFrame()) { |
const base::TimeTicks present_time = base::TimeTicks::Now(); |
scoped_refptr<media::VideoFrame> frame; |
RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; |
- if (frame_subscriber()->ShouldCaptureFrame(present_time, |
- &frame, &callback)) { |
+ if (frame_subscriber()->ShouldCaptureFrame( |
+ present_time, &frame, &callback)) { |
CopyFromCompositingSurfaceToVideoFrame( |
gfx::Rect(current_frame_size_in_dip_), |
frame, |
@@ -263,7 +246,7 @@ void DelegatedFrameHost::DidReceiveFrameFromRenderer() { |
} |
} |
-void DelegatedFrameHost::SwapDelegatedFrame( |
+void DelegatedFrameSurfaceHost::SwapDelegatedFrame( |
uint32 output_surface_id, |
scoped_ptr<cc::DelegatedFrameData> frame_data, |
float frame_device_scale_factor, |
@@ -288,11 +271,14 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
&ack.resources); |
skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), |
- latency_info.begin(), latency_info.end()); |
+ latency_info.begin(), |
+ latency_info.end()); |
RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
- host->GetRoutingID(), output_surface_id, |
- host->GetProcess()->GetID(), ack); |
+ host->GetRoutingID(), |
+ output_surface_id, |
+ host->GetProcess()->GetID(), |
+ ack); |
skipped_frames_ = true; |
return; |
} |
@@ -319,38 +305,31 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
// Drop the cc::DelegatedFrameResourceCollection so that we will not return |
// any resources from the old output surface with the new output surface id. |
- if (resource_collection_.get()) { |
- resource_collection_->SetClient(NULL); |
- |
- if (resource_collection_->LoseAllResources()) |
- SendReturnedDelegatedResources(last_output_surface_id_); |
- |
- resource_collection_ = NULL; |
- } |
last_output_surface_id_ = output_surface_id; |
} |
if (frame_size.IsEmpty()) { |
DCHECK(frame_data->resource_list.empty()); |
EvictDelegatedFrame(); |
} else { |
- if (!resource_collection_) { |
- resource_collection_ = new cc::DelegatedFrameResourceCollection; |
- resource_collection_->SetClient(this); |
+ if (!surface_factory_) { |
+ ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
+ cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
+ id_allocator_ = factory->CreateSurfaceIdAllocator(); |
+ surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
} |
- // If the physical frame size changes, we need a new |frame_provider_|. If |
- // the physical frame size is the same, but the size in DIP changed, we |
- // need to adjust the scale at which the frames will be drawn, and we do |
- // this by making a new |frame_provider_| also to ensure the scale change |
- // is presented in sync with the new frame content. |
- if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() || |
+ if (surface_id_.is_null() || frame_size != current_surface_size_ || |
frame_size_in_dip != current_frame_size_in_dip_) { |
- frame_provider_ = new cc::DelegatedFrameProvider( |
- resource_collection_.get(), frame_data.Pass()); |
- client_->GetLayer()->SetShowDelegatedContent(frame_provider_.get(), |
- frame_size_in_dip); |
- } else { |
- frame_provider_->SetFrameData(frame_data.Pass()); |
+ if (!surface_id_.is_null()) |
+ surface_factory_->Destroy(surface_id_); |
+ surface_id_ = id_allocator_->GenerateId(); |
+ surface_factory_->Create(surface_id_, frame_size); |
+ client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
+ current_surface_size_ = frame_size; |
} |
+ scoped_ptr<cc::CompositorFrame> compositor_frame = |
+ make_scoped_ptr(new cc::CompositorFrame()); |
+ compositor_frame->delegated_frame_data = frame_data.Pass(); |
+ surface_factory_->SubmitFrame(surface_id_, compositor_frame.Pass()); |
} |
released_front_lock_ = NULL; |
current_frame_size_in_dip_ = frame_size_in_dip; |
@@ -369,26 +348,41 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
compositor->SetLatencyInfo(*it); |
// If we've previously skipped any latency infos add them. |
for (it = skipped_latency_info_list_.begin(); |
- it != skipped_latency_info_list_.end(); |
- ++it) |
+ it != skipped_latency_info_list_.end(); |
+ ++it) |
compositor->SetLatencyInfo(*it); |
skipped_latency_info_list_.clear(); |
AddOnCommitCallbackAndDisableLocks( |
- base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, |
+ base::Bind(&DelegatedFrameSurfaceHost::SendDelegatedFrameAck, |
AsWeakPtr(), |
output_surface_id)); |
} |
DidReceiveFrameFromRenderer(); |
- if (frame_provider_.get()) |
+ if (!surface_id_.is_null()) |
delegated_frame_evictor_->SwappedFrame(!host->is_hidden()); |
// Note: the frame may have been evicted immediately. |
} |
-void DelegatedFrameHost::SendDelegatedFrameAck(uint32 output_surface_id) { |
+void DelegatedFrameSurfaceHost::SetLayerOwner(ui::LayerOwner* layer_owner) { |
+ layer_owner->set_layer_owner_delegate(this); |
+} |
+ |
+cc::DelegatedFrameProvider* DelegatedFrameSurfaceHost::FrameProviderForTesting() |
+ const { |
+ return NULL; |
+} |
+ |
+void DelegatedFrameSurfaceHost::OnCompositingDidCommitForTesting( |
+ ui::Compositor* compositor) { |
+ OnCompositingDidCommit(compositor); |
+} |
+ |
+void DelegatedFrameSurfaceHost::SendDelegatedFrameAck( |
+ uint32 output_surface_id) { |
RenderWidgetHostImpl* host = client_->GetHost(); |
cc::CompositorFrameAck ack; |
- if (resource_collection_) |
- resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); |
+ if (!surface_returned_resources_.empty()) |
+ ack.resources.swap(surface_returned_resources_); |
RenderWidgetHostImpl::SendSwapCompositorFrameAck(host->GetRoutingID(), |
output_surface_id, |
host->GetProcess()->GetID(), |
@@ -397,20 +391,14 @@ void DelegatedFrameHost::SendDelegatedFrameAck(uint32 output_surface_id) { |
pending_delegated_ack_count_--; |
} |
-void DelegatedFrameHost::UnusedResourcesAreAvailable() { |
- if (pending_delegated_ack_count_) |
- return; |
- |
- SendReturnedDelegatedResources(last_output_surface_id_); |
-} |
- |
-void DelegatedFrameHost::SendReturnedDelegatedResources( |
+void DelegatedFrameSurfaceHost::SendReturnedDelegatedResources( |
uint32 output_surface_id) { |
RenderWidgetHostImpl* host = client_->GetHost(); |
- DCHECK(resource_collection_); |
cc::CompositorFrameAck ack; |
- resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); |
+ if (!surface_returned_resources_.empty()) { |
piman
2014/07/25 01:27:42
This if can go away, the only caller is ReturnReso
|
+ ack.resources.swap(surface_returned_resources_); |
+ } |
DCHECK(!ack.resources.empty()); |
RenderWidgetHostImpl::SendReclaimCompositorResources( |
@@ -420,14 +408,28 @@ void DelegatedFrameHost::SendReturnedDelegatedResources( |
ack); |
} |
-void DelegatedFrameHost::EvictDelegatedFrame() { |
+void DelegatedFrameSurfaceHost::ReturnResources( |
+ const cc::ReturnedResourceArray& resources) { |
+ if (resources.empty()) |
+ return; |
+ std::copy(resources.begin(), |
+ resources.end(), |
+ std::back_inserter(surface_returned_resources_)); |
+ if (!pending_delegated_ack_count_) |
+ SendReturnedDelegatedResources(last_output_surface_id_); |
+} |
+ |
+void DelegatedFrameSurfaceHost::EvictDelegatedFrame() { |
client_->GetLayer()->SetShowPaintedContent(); |
- frame_provider_ = NULL; |
+ if (!surface_id_.is_null()) { |
+ surface_factory_->Destroy(surface_id_); |
+ surface_id_ = cc::SurfaceId(); |
+ } |
delegated_frame_evictor_->DiscardedFrame(); |
} |
// static |
-void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( |
+void DelegatedFrameSurfaceHost::CopyFromCompositingSurfaceHasResult( |
const gfx::Size& dst_size_in_pixel, |
const SkColorType color_type, |
const base::Callback<void(bool, const SkBitmap&)>& callback, |
@@ -438,15 +440,14 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( |
} |
if (result->HasTexture()) { |
- PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, |
- callback, |
- result.Pass()); |
+ PrepareTextureCopyOutputResult( |
+ dst_size_in_pixel, color_type, callback, result.Pass()); |
return; |
} |
DCHECK(result->HasBitmap()); |
- PrepareBitmapCopyOutputResult(dst_size_in_pixel, color_type, callback, |
- result.Pass()); |
+ PrepareBitmapCopyOutputResult( |
+ dst_size_in_pixel, color_type, callback, result.Pass()); |
} |
static void CopyFromCompositingSurfaceFinished( |
@@ -469,7 +470,7 @@ static void CopyFromCompositingSurfaceFinished( |
} |
// static |
-void DelegatedFrameHost::PrepareTextureCopyOutputResult( |
+void DelegatedFrameSurfaceHost::PrepareTextureCopyOutputResult( |
const gfx::Size& dst_size_in_pixel, |
const SkColorType color_type, |
const base::Callback<void(bool, const SkBitmap&)>& callback, |
@@ -518,7 +519,7 @@ void DelegatedFrameHost::PrepareTextureCopyOutputResult( |
} |
// static |
-void DelegatedFrameHost::PrepareBitmapCopyOutputResult( |
+void DelegatedFrameSurfaceHost::PrepareBitmapCopyOutputResult( |
const gfx::Size& dst_size_in_pixel, |
const SkColorType color_type, |
const base::Callback<void(bool, const SkBitmap&)>& callback, |
@@ -531,17 +532,17 @@ void DelegatedFrameHost::PrepareBitmapCopyOutputResult( |
DCHECK(result->HasBitmap()); |
scoped_ptr<SkBitmap> source = result->TakeBitmap(); |
DCHECK(source); |
- SkBitmap bitmap = skia::ImageOperations::Resize( |
- *source, |
- skia::ImageOperations::RESIZE_BEST, |
- dst_size_in_pixel.width(), |
- dst_size_in_pixel.height()); |
+ SkBitmap bitmap = |
+ skia::ImageOperations::Resize(*source, |
+ skia::ImageOperations::RESIZE_BEST, |
+ dst_size_in_pixel.width(), |
+ dst_size_in_pixel.height()); |
callback.Run(true, bitmap); |
} |
// static |
-void DelegatedFrameHost::ReturnSubscriberTexture( |
- base::WeakPtr<DelegatedFrameHost> dfh, |
+void DelegatedFrameSurfaceHost::ReturnSubscriberTexture( |
+ base::WeakPtr<DelegatedFrameSurfaceHost> dfh, |
scoped_refptr<OwnedMailbox> subscriber_texture, |
uint32 sync_point) { |
if (!subscriber_texture.get()) |
@@ -555,8 +556,8 @@ void DelegatedFrameHost::ReturnSubscriberTexture( |
dfh->idle_frame_subscriber_textures_.push_back(subscriber_texture); |
} |
-void DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo( |
- base::WeakPtr<DelegatedFrameHost> dfh, |
+void DelegatedFrameSurfaceHost::CopyFromCompositingSurfaceFinishedForVideo( |
+ base::WeakPtr<DelegatedFrameSurfaceHost> dfh, |
const base::Callback<void(bool)>& callback, |
scoped_refptr<OwnedMailbox> subscriber_texture, |
scoped_ptr<cc::SingleReleaseCallback> release_callback, |
@@ -579,8 +580,8 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo( |
} |
// static |
-void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
- base::WeakPtr<DelegatedFrameHost> dfh, |
+void DelegatedFrameSurfaceHost::CopyFromCompositingSurfaceHasResultForVideo( |
+ base::WeakPtr<DelegatedFrameSurfaceHost> dfh, |
scoped_refptr<OwnedMailbox> subscriber_texture, |
scoped_refptr<media::VideoFrame> video_frame, |
const base::Callback<void(bool)>& callback, |
@@ -602,9 +603,8 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
// line up correctly. |
// The video frame's coded_size() and the result's size() are both physical |
// pixels. |
- gfx::Rect region_in_frame = |
- media::ComputeLetterboxRegion(gfx::Rect(video_frame->coded_size()), |
- result->size()); |
+ gfx::Rect region_in_frame = media::ComputeLetterboxRegion( |
+ gfx::Rect(video_frame->coded_size()), result->size()); |
region_in_frame = gfx::Rect(region_in_frame.x() & ~1, |
region_in_frame.y() & ~1, |
region_in_frame.width() & ~1, |
@@ -621,7 +621,8 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
result->size().height() != region_in_frame.height()) { |
skia::ImageOperations::ResizeMethod method = |
skia::ImageOperations::RESIZE_GOOD; |
- scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), method, |
+ scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), |
+ method, |
region_in_frame.width(), |
region_in_frame.height()); |
} else { |
@@ -692,7 +693,7 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
ignore_result(scoped_callback_runner.Release()); |
ignore_result(scoped_return_subscriber_texture.Release()); |
base::Callback<void(bool result)> finished_callback = base::Bind( |
- &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo, |
+ &DelegatedFrameSurfaceHost::CopyFromCompositingSurfaceFinishedForVideo, |
dfh->AsWeakPtr(), |
callback, |
subscriber_texture, |
@@ -704,9 +705,9 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
} |
//////////////////////////////////////////////////////////////////////////////// |
-// DelegatedFrameHost, ui::CompositorObserver implementation: |
+// DelegatedFrameSurfaceHost, ui::CompositorObserver implementation: |
-void DelegatedFrameHost::OnCompositingDidCommit( |
+void DelegatedFrameSurfaceHost::OnCompositingDidCommit( |
ui::Compositor* compositor) { |
RenderWidgetHostImpl* host = client_->GetHost(); |
if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
@@ -726,19 +727,20 @@ void DelegatedFrameHost::OnCompositingDidCommit( |
} |
} |
-void DelegatedFrameHost::OnCompositingStarted( |
- ui::Compositor* compositor, base::TimeTicks start_time) { |
+void DelegatedFrameSurfaceHost::OnCompositingStarted( |
+ ui::Compositor* compositor, |
+ base::TimeTicks start_time) { |
last_draw_ended_ = start_time; |
} |
-void DelegatedFrameHost::OnCompositingEnded( |
- ui::Compositor* compositor) { |
+void DelegatedFrameSurfaceHost::OnCompositingEnded(ui::Compositor* compositor) { |
} |
-void DelegatedFrameHost::OnCompositingAborted(ui::Compositor* compositor) { |
+void DelegatedFrameSurfaceHost::OnCompositingAborted( |
+ ui::Compositor* compositor) { |
} |
-void DelegatedFrameHost::OnCompositingLockStateChanged( |
+void DelegatedFrameSurfaceHost::OnCompositingLockStateChanged( |
ui::Compositor* compositor) { |
// A compositor lock that is part of a resize lock timed out. We |
// should display a renderer frame. |
@@ -747,7 +749,7 @@ void DelegatedFrameHost::OnCompositingLockStateChanged( |
} |
} |
-void DelegatedFrameHost::OnUpdateVSyncParameters( |
+void DelegatedFrameSurfaceHost::OnUpdateVSyncParameters( |
base::TimeTicks timebase, |
base::TimeDelta interval) { |
RenderWidgetHostImpl* host = client_->GetHost(); |
@@ -758,9 +760,9 @@ void DelegatedFrameHost::OnUpdateVSyncParameters( |
//////////////////////////////////////////////////////////////////////////////// |
// RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
-void DelegatedFrameHost::OnLostResources() { |
+void DelegatedFrameSurfaceHost::OnLostResources() { |
RenderWidgetHostImpl* host = client_->GetHost(); |
- if (frame_provider_.get()) |
+ if (!surface_id_.is_null()) |
EvictDelegatedFrame(); |
idle_frame_subscriber_textures_.clear(); |
yuv_readback_pipeline_.reset(); |
@@ -769,27 +771,27 @@ void DelegatedFrameHost::OnLostResources() { |
} |
//////////////////////////////////////////////////////////////////////////////// |
-// DelegatedFrameHost, private: |
+// DelegatedFrameSurfaceHost, private: |
-DelegatedFrameHost::~DelegatedFrameHost() { |
+DelegatedFrameSurfaceHost::~DelegatedFrameSurfaceHost() { |
ImageTransportFactory::GetInstance()->RemoveObserver(this); |
- if (resource_collection_.get()) |
- resource_collection_->SetClient(NULL); |
- |
+ if (!surface_id_.is_null()) |
+ surface_factory_->Destroy(surface_id_); |
DCHECK(!vsync_manager_); |
} |
-void DelegatedFrameHost::RunOnCommitCallbacks() { |
- for (std::vector<base::Closure>::const_iterator |
- it = on_compositing_did_commit_callbacks_.begin(); |
- it != on_compositing_did_commit_callbacks_.end(); ++it) { |
+void DelegatedFrameSurfaceHost::RunOnCommitCallbacks() { |
+ for (std::vector<base::Closure>::const_iterator it = |
+ on_compositing_did_commit_callbacks_.begin(); |
+ it != on_compositing_did_commit_callbacks_.end(); |
+ ++it) { |
it->Run(); |
} |
on_compositing_did_commit_callbacks_.clear(); |
} |
-void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( |
+void DelegatedFrameSurfaceHost::AddOnCommitCallbackAndDisableLocks( |
const base::Closure& callback) { |
ui::Compositor* compositor = client_->GetCompositor(); |
DCHECK(compositor); |
@@ -801,7 +803,7 @@ void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( |
on_compositing_did_commit_callbacks_.push_back(callback); |
} |
-void DelegatedFrameHost::AddedToWindow() { |
+void DelegatedFrameSurfaceHost::AddedToWindow() { |
ui::Compositor* compositor = client_->GetCompositor(); |
if (compositor) { |
DCHECK(!vsync_manager_); |
@@ -810,7 +812,7 @@ void DelegatedFrameHost::AddedToWindow() { |
} |
} |
-void DelegatedFrameHost::RemovingFromWindow() { |
+void DelegatedFrameSurfaceHost::RemovingFromWindow() { |
RunOnCommitCallbacks(); |
resize_lock_.reset(); |
client_->GetHost()->WasResized(); |
@@ -824,29 +826,28 @@ void DelegatedFrameHost::RemovingFromWindow() { |
} |
} |
-void DelegatedFrameHost::LockResources() { |
- DCHECK(frame_provider_); |
+void DelegatedFrameSurfaceHost::LockResources() { |
+ DCHECK(!surface_id_.is_null()); |
delegated_frame_evictor_->LockFrame(); |
} |
-void DelegatedFrameHost::UnlockResources() { |
- DCHECK(frame_provider_); |
+void DelegatedFrameSurfaceHost::UnlockResources() { |
+ DCHECK(!surface_id_.is_null()); |
delegated_frame_evictor_->UnlockFrame(); |
} |
//////////////////////////////////////////////////////////////////////////////// |
-// DelegatedFrameHost, ui::LayerOwnerDelegate implementation: |
+// DelegatedFrameSurfaceHost, ui::LayerOwnerDelegate implementation: |
-void DelegatedFrameHost::OnLayerRecreated(ui::Layer* old_layer, |
- ui::Layer* new_layer) { |
+void DelegatedFrameSurfaceHost::OnLayerRecreated(ui::Layer* old_layer, |
+ ui::Layer* new_layer) { |
// The new_layer is the one that will be used by our Window, so that's the one |
// that should keep our frame. old_layer will be returned to the |
// RecreateLayer caller, and should have a copy. |
- if (frame_provider_.get()) { |
- new_layer->SetShowDelegatedContent(frame_provider_.get(), |
- current_frame_size_in_dip_); |
+ if (!surface_id_.is_null()) { |
+ client_->GetLayer()->SetShowSurface(surface_id_, |
+ current_frame_size_in_dip_); |
} |
} |
} // namespace content |
- |