OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/child_frame_compositing_helper.h" | 5 #include "content/renderer/child_frame_compositing_helper.h" |
6 | 6 |
7 #include "cc/blink/web_layer_impl.h" | 7 #include "cc/blink/web_layer_impl.h" |
8 #include "cc/layers/delegated_frame_provider.h" | 8 #include "cc/layers/delegated_frame_provider.h" |
9 #include "cc/layers/delegated_frame_resource_collection.h" | 9 #include "cc/layers/delegated_frame_resource_collection.h" |
10 #include "cc/layers/delegated_renderer_layer.h" | 10 #include "cc/layers/delegated_renderer_layer.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (GetBrowserPluginManager()) { | 105 if (GetBrowserPluginManager()) { |
106 GetBrowserPluginManager()->Send( | 106 GetBrowserPluginManager()->Send( |
107 new BrowserPluginHostMsg_ReclaimCompositorResources( | 107 new BrowserPluginHostMsg_ReclaimCompositorResources( |
108 host_routing_id_, GetInstanceID(), params)); | 108 host_routing_id_, GetInstanceID(), params)); |
109 } else if (render_frame_proxy_) { | 109 } else if (render_frame_proxy_) { |
110 render_frame_proxy_->Send( | 110 render_frame_proxy_->Send( |
111 new FrameHostMsg_ReclaimCompositorResources(host_routing_id_, params)); | 111 new FrameHostMsg_ReclaimCompositorResources(host_routing_id_, params)); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 void ChildFrameCompositingHelper::CopyFromCompositingSurface( | |
116 int request_id, | |
117 gfx::Rect source_rect, | |
118 gfx::Size dest_size) { | |
119 CHECK(background_layer_.get()); | |
120 scoped_ptr<cc::CopyOutputRequest> request = | |
121 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( | |
122 &ChildFrameCompositingHelper::CopyFromCompositingSurfaceHasResult, | |
123 this, | |
124 request_id, | |
125 dest_size)); | |
126 request->set_area(source_rect); | |
127 background_layer_->RequestCopyOfOutput(request.Pass()); | |
128 } | |
129 | |
130 void ChildFrameCompositingHelper::DidCommitCompositorFrame() { | 115 void ChildFrameCompositingHelper::DidCommitCompositorFrame() { |
131 if (!resource_collection_.get() || !ack_pending_) | 116 if (!resource_collection_.get() || !ack_pending_) |
132 return; | 117 return; |
133 | 118 |
134 FrameHostMsg_CompositorFrameSwappedACK_Params params; | 119 FrameHostMsg_CompositorFrameSwappedACK_Params params; |
135 params.producing_host_id = last_host_id_; | 120 params.producing_host_id = last_host_id_; |
136 params.producing_route_id = last_route_id_; | 121 params.producing_route_id = last_route_id_; |
137 params.output_surface_id = last_output_surface_id_; | 122 params.output_surface_id = last_output_surface_id_; |
138 resource_collection_->TakeUnusedResourcesForChildCompositor( | 123 resource_collection_->TakeUnusedResourcesForChildCompositor( |
139 ¶ms.ack.resources); | 124 ¶ms.ack.resources); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 params.renderer_host_id = last_host_id_; | 275 params.renderer_host_id = last_host_id_; |
291 SendReclaimCompositorResourcesToBrowser(params); | 276 SendReclaimCompositorResourcesToBrowser(params); |
292 } | 277 } |
293 | 278 |
294 void ChildFrameCompositingHelper::SetContentsOpaque(bool opaque) { | 279 void ChildFrameCompositingHelper::SetContentsOpaque(bool opaque) { |
295 opaque_ = opaque; | 280 opaque_ = opaque; |
296 if (delegated_layer_.get()) | 281 if (delegated_layer_.get()) |
297 delegated_layer_->SetContentsOpaque(opaque_); | 282 delegated_layer_->SetContentsOpaque(opaque_); |
298 } | 283 } |
299 | 284 |
300 void ChildFrameCompositingHelper::CopyFromCompositingSurfaceHasResult( | |
301 int request_id, | |
302 gfx::Size dest_size, | |
303 scoped_ptr<cc::CopyOutputResult> result) { | |
304 scoped_ptr<SkBitmap> bitmap; | |
305 if (result && result->HasBitmap() && !result->size().IsEmpty()) | |
306 bitmap = result->TakeBitmap(); | |
307 | |
308 SkBitmap resized_bitmap; | |
309 if (bitmap) { | |
310 resized_bitmap = | |
311 skia::ImageOperations::Resize(*bitmap, | |
312 skia::ImageOperations::RESIZE_BEST, | |
313 dest_size.width(), | |
314 dest_size.height()); | |
315 } | |
316 if (GetBrowserPluginManager()) { | |
317 GetBrowserPluginManager()->Send( | |
318 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | |
319 host_routing_id_, GetInstanceID(), request_id, resized_bitmap)); | |
320 } | |
321 } | |
322 | |
323 } // namespace content | 285 } // namespace content |
OLD | NEW |