| 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/browser/compositor/delegated_frame_host.h" | 5 #include "content/browser/compositor/delegated_frame_host.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 callback.Run(SkBitmap(), content::READBACK_SURFACE_UNAVAILABLE); | 173 callback.Run(SkBitmap(), content::READBACK_SURFACE_UNAVAILABLE); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 | 176 |
| 177 scoped_ptr<cc::CopyOutputRequest> request = | 177 scoped_ptr<cc::CopyOutputRequest> request = |
| 178 cc::CopyOutputRequest::CreateRequest(base::Bind( | 178 cc::CopyOutputRequest::CreateRequest(base::Bind( |
| 179 &DelegatedFrameHost::CopyFromCompositingSurfaceHasResult, | 179 &DelegatedFrameHost::CopyFromCompositingSurfaceHasResult, |
| 180 output_size, | 180 output_size, |
| 181 color_type, | 181 color_type, |
| 182 callback)); | 182 callback)); |
| 183 request->set_area(src_subrect); | 183 if (!src_subrect.IsEmpty()) |
| 184 request->set_area(src_subrect); |
| 184 client_->RequestCopyOfOutput(request.Pass()); | 185 client_->RequestCopyOfOutput(request.Pass()); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( | 188 void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( |
| 188 const gfx::Rect& src_subrect, | 189 const gfx::Rect& src_subrect, |
| 189 const scoped_refptr<media::VideoFrame>& target, | 190 const scoped_refptr<media::VideoFrame>& target, |
| 190 const base::Callback<void(bool)>& callback) { | 191 const base::Callback<void(bool)>& callback) { |
| 191 if (!CanCopyToVideoFrame()) { | 192 if (!CanCopyToVideoFrame()) { |
| 192 callback.Run(false); | 193 callback.Run(false); |
| 193 return; | 194 return; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( | 558 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( |
| 558 const gfx::Size& dst_size_in_pixel, | 559 const gfx::Size& dst_size_in_pixel, |
| 559 const SkColorType color_type, | 560 const SkColorType color_type, |
| 560 ReadbackRequestCallback& callback, | 561 ReadbackRequestCallback& callback, |
| 561 scoped_ptr<cc::CopyOutputResult> result) { | 562 scoped_ptr<cc::CopyOutputResult> result) { |
| 562 if (result->IsEmpty() || result->size().IsEmpty()) { | 563 if (result->IsEmpty() || result->size().IsEmpty()) { |
| 563 callback.Run(SkBitmap(), content::READBACK_FAILED); | 564 callback.Run(SkBitmap(), content::READBACK_FAILED); |
| 564 return; | 565 return; |
| 565 } | 566 } |
| 566 | 567 |
| 568 gfx::Size output_size_in_pixel; |
| 569 if (dst_size_in_pixel.IsEmpty()) |
| 570 output_size_in_pixel = result->size(); |
| 571 else |
| 572 output_size_in_pixel = dst_size_in_pixel; |
| 573 |
| 567 if (result->HasTexture()) { | 574 if (result->HasTexture()) { |
| 568 // GPU-accelerated path | 575 // GPU-accelerated path |
| 569 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, | 576 PrepareTextureCopyOutputResult(output_size_in_pixel, color_type, |
| 570 callback, | 577 callback, |
| 571 result.Pass()); | 578 result.Pass()); |
| 572 return; | 579 return; |
| 573 } | 580 } |
| 574 | 581 |
| 575 DCHECK(result->HasBitmap()); | 582 DCHECK(result->HasBitmap()); |
| 576 // Software path | 583 // Software path |
| 577 PrepareBitmapCopyOutputResult(dst_size_in_pixel, color_type, callback, | 584 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, |
| 578 result.Pass()); | 585 result.Pass()); |
| 579 } | 586 } |
| 580 | 587 |
| 581 static void CopyFromCompositingSurfaceFinished( | 588 static void CopyFromCompositingSurfaceFinished( |
| 582 ReadbackRequestCallback& callback, | 589 ReadbackRequestCallback& callback, |
| 583 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 590 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| 584 scoped_ptr<SkBitmap> bitmap, | 591 scoped_ptr<SkBitmap> bitmap, |
| 585 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 592 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| 586 bool result) { | 593 bool result) { |
| 587 bitmap_pixels_lock.reset(); | 594 bitmap_pixels_lock.reset(); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1028 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1022 new_layer->SetShowSurface( | 1029 new_layer->SetShowSurface( |
| 1023 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1030 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 1024 base::Bind(&RequireCallback, base::Unretained(manager)), | 1031 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 1025 current_surface_size_, current_scale_factor_, | 1032 current_surface_size_, current_scale_factor_, |
| 1026 current_frame_size_in_dip_); | 1033 current_frame_size_in_dip_); |
| 1027 } | 1034 } |
| 1028 } | 1035 } |
| 1029 | 1036 |
| 1030 } // namespace content | 1037 } // namespace content |
| OLD | NEW |