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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 146873002: Handle Left out paths on Android/Aura for Async ReadBack. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WIP:Handle Left out paths on Android/Aura for Async ReadBack Created 6 years, 11 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 float device_scale_factor = display.device_scale_factor(); 663 float device_scale_factor = display.device_scale_factor();
664 664
665 DCHECK_EQ(device_scale_factor, 665 DCHECK_EQ(device_scale_factor,
666 ui::GetImageScale(GetScaleFactorForView(this))); 666 ui::GetImageScale(GetScaleFactorForView(this)));
667 667
668 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); 668 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size);
669 gfx::Rect src_subrect_in_pixel = 669 gfx::Rect src_subrect_in_pixel =
670 ConvertRectToPixel(device_scale_factor, src_subrect); 670 ConvertRectToPixel(device_scale_factor, src_subrect);
671 671
672 if (using_synchronous_compositor_) { 672 if (using_synchronous_compositor_) {
673 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback); 673 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback,
674 bitmap_config);
674 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", 675 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous",
675 base::TimeTicks::Now() - start_time); 676 base::TimeTicks::Now() - start_time);
676 return; 677 return;
677 } 678 }
678 scoped_ptr<cc::CopyOutputRequest> request; 679 scoped_ptr<cc::CopyOutputRequest> request;
679 if (src_subrect_in_pixel.size() == dst_size_in_pixel) { 680 if (src_subrect_in_pixel.size() == dst_size_in_pixel) {
680 request = cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( 681 request = cc::CopyOutputRequest::CreateBitmapRequest(base::Bind(
681 &RenderWidgetHostViewAndroid::PrepareBitmapCopyOutputResult, 682 &RenderWidgetHostViewAndroid::PrepareBitmapCopyOutputResult,
682 dst_size_in_pixel, 683 dst_size_in_pixel,
684 bitmap_config,
683 start_time, 685 start_time,
684 callback)); 686 callback));
685 } else { 687 } else {
686 request = cc::CopyOutputRequest::CreateRequest(base::Bind( 688 request = cc::CopyOutputRequest::CreateRequest(base::Bind(
687 &RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult, 689 &RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult,
688 dst_size_in_pixel, 690 dst_size_in_pixel,
689 bitmap_config, 691 bitmap_config,
690 start_time, 692 start_time,
691 callback)); 693 callback));
692 } 694 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 } 903 }
902 } 904 }
903 905
904 void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) { 906 void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) {
905 layer_->SetContentsOpaque(!enabled); 907 layer_->SetContentsOpaque(!enabled);
906 } 908 }
907 909
908 void RenderWidgetHostViewAndroid::SynchronousCopyContents( 910 void RenderWidgetHostViewAndroid::SynchronousCopyContents(
909 const gfx::Rect& src_subrect_in_pixel, 911 const gfx::Rect& src_subrect_in_pixel,
910 const gfx::Size& dst_size_in_pixel, 912 const gfx::Size& dst_size_in_pixel,
911 const base::Callback<void(bool, const SkBitmap&)>& callback) { 913 const base::Callback<void(bool, const SkBitmap&)>& callback,
914 const SkBitmap::Config config) {
912 SynchronousCompositor* compositor = 915 SynchronousCompositor* compositor =
913 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), 916 SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(),
914 host_->GetRoutingID()); 917 host_->GetRoutingID());
915 if (!compositor) { 918 if (!compositor) {
916 callback.Run(false, SkBitmap()); 919 callback.Run(false, SkBitmap());
917 return; 920 return;
918 } 921 }
919 922
920 SkBitmap bitmap; 923 SkBitmap bitmap;
921 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 924 bitmap.setConfig(config,
922 dst_size_in_pixel.width(), 925 dst_size_in_pixel.width(),
923 dst_size_in_pixel.height()); 926 dst_size_in_pixel.height());
924 bitmap.allocPixels(); 927 bitmap.allocPixels();
925 SkCanvas canvas(bitmap); 928 SkCanvas canvas(bitmap);
926 canvas.scale( 929 canvas.scale(
927 (float)dst_size_in_pixel.width() / (float)src_subrect_in_pixel.width(), 930 (float)dst_size_in_pixel.width() / (float)src_subrect_in_pixel.width(),
928 (float)dst_size_in_pixel.height() / (float)src_subrect_in_pixel.height()); 931 (float)dst_size_in_pixel.height() / (float)src_subrect_in_pixel.height());
929 compositor->DemandDrawSw(&canvas); 932 compositor->DemandDrawSw(&canvas);
930 callback.Run(true, bitmap); 933 callback.Run(true, bitmap);
931 } 934 }
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 callback, 1462 callback,
1460 base::Passed(&release_callback), 1463 base::Passed(&release_callback),
1461 base::Passed(&bitmap), 1464 base::Passed(&bitmap),
1462 start_time, 1465 start_time,
1463 base::Passed(&bitmap_pixels_lock))); 1466 base::Passed(&bitmap_pixels_lock)));
1464 } 1467 }
1465 1468
1466 // static 1469 // static
1467 void RenderWidgetHostViewAndroid::PrepareBitmapCopyOutputResult( 1470 void RenderWidgetHostViewAndroid::PrepareBitmapCopyOutputResult(
1468 const gfx::Size& dst_size_in_pixel, 1471 const gfx::Size& dst_size_in_pixel,
1472 const SkBitmap::Config config,
1469 const base::TimeTicks& start_time, 1473 const base::TimeTicks& start_time,
1470 const base::Callback<void(bool, const SkBitmap&)>& callback, 1474 const base::Callback<void(bool, const SkBitmap&)>& callback,
1471 scoped_ptr<cc::CopyOutputResult> result) { 1475 scoped_ptr<cc::CopyOutputResult> result) {
1476 //We have to draw to a new 565 bitmap and return that.
no sievers 2014/01/25 00:18:23 Do we just need to force it through the texture co
sivag 2014/01/25 17:38:46 You mean to say, when the src_subrect_in_pixel.siz
sivag 2014/01/27 15:12:16 Done.
sivag 2014/01/27 15:12:16 Done.
1477 if (config != SkBitmap::kARGB_8888_Config) {
1478 NOTIMPLEMENTED();
1479 callback.Run(false, SkBitmap());
1480 }
1472 DCHECK(result->HasBitmap()); 1481 DCHECK(result->HasBitmap());
1473 base::ScopedClosureRunner scoped_callback_runner( 1482 base::ScopedClosureRunner scoped_callback_runner(
1474 base::Bind(callback, false, SkBitmap())); 1483 base::Bind(callback, false, SkBitmap()));
1475 1484
1476 if (!result->HasBitmap() || result->IsEmpty() || result->size().IsEmpty()) 1485 if (!result->HasBitmap() || result->IsEmpty() || result->size().IsEmpty())
1477 return; 1486 return;
1478 1487
1479 scoped_ptr<SkBitmap> source = result->TakeBitmap(); 1488 scoped_ptr<SkBitmap> source = result->TakeBitmap();
1480 DCHECK(source); 1489 DCHECK(source);
1481 if (!source) 1490 if (!source)
(...skipping 28 matching lines...) Expand all
1510 // RenderWidgetHostView, public: 1519 // RenderWidgetHostView, public:
1511 1520
1512 // static 1521 // static
1513 RenderWidgetHostView* 1522 RenderWidgetHostView*
1514 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 1523 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
1515 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 1524 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
1516 return new RenderWidgetHostViewAndroid(rwhi, NULL); 1525 return new RenderWidgetHostViewAndroid(rwhi, NULL);
1517 } 1526 }
1518 1527
1519 } // namespace content 1528 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698