Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: content/browser/compositor/delegated_frame_host.cc

Issue 802343002: Add ability to copy unscaled output pixels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( 563 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult(
563 const gfx::Size& dst_size_in_pixel, 564 const gfx::Size& dst_size_in_pixel,
564 const SkColorType color_type, 565 const SkColorType color_type,
565 ReadbackRequestCallback& callback, 566 ReadbackRequestCallback& callback,
566 scoped_ptr<cc::CopyOutputResult> result) { 567 scoped_ptr<cc::CopyOutputResult> result) {
567 if (result->IsEmpty() || result->size().IsEmpty()) { 568 if (result->IsEmpty() || result->size().IsEmpty()) {
568 callback.Run(SkBitmap(), content::READBACK_FAILED); 569 callback.Run(SkBitmap(), content::READBACK_FAILED);
569 return; 570 return;
570 } 571 }
571 572
573 gfx::Size output_size_in_pixel;
574 if (dst_size_in_pixel.IsEmpty())
575 output_size_in_pixel = result->size();
576 else
577 output_size_in_pixel = dst_size_in_pixel;
578
572 if (result->HasTexture()) { 579 if (result->HasTexture()) {
573 // GPU-accelerated path 580 // GPU-accelerated path
574 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, 581 PrepareTextureCopyOutputResult(output_size_in_pixel, color_type,
575 callback, 582 callback,
576 result.Pass()); 583 result.Pass());
577 return; 584 return;
578 } 585 }
579 586
580 DCHECK(result->HasBitmap()); 587 DCHECK(result->HasBitmap());
581 // Software path 588 // Software path
582 PrepareBitmapCopyOutputResult(dst_size_in_pixel, color_type, callback, 589 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
583 result.Pass()); 590 result.Pass());
584 } 591 }
585 592
586 static void CopyFromCompositingSurfaceFinished( 593 static void CopyFromCompositingSurfaceFinished(
587 ReadbackRequestCallback& callback, 594 ReadbackRequestCallback& callback,
588 scoped_ptr<cc::SingleReleaseCallback> release_callback, 595 scoped_ptr<cc::SingleReleaseCallback> release_callback,
589 scoped_ptr<SkBitmap> bitmap, 596 scoped_ptr<SkBitmap> bitmap,
590 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 597 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
591 bool result) { 598 bool result) {
592 bitmap_pixels_lock.reset(); 599 bitmap_pixels_lock.reset();
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1033 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1027 new_layer->SetShowSurface( 1034 new_layer->SetShowSurface(
1028 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1035 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1029 base::Bind(&RequireCallback, base::Unretained(manager)), 1036 base::Bind(&RequireCallback, base::Unretained(manager)),
1030 current_surface_size_, current_scale_factor_, 1037 current_surface_size_, current_scale_factor_,
1031 current_frame_size_in_dip_); 1038 current_frame_size_in_dip_);
1032 } 1039 }
1033 } 1040 }
1034 1041
1035 } // namespace content 1042 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698