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

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

Issue 336433003: Clobber frame_data->device_scale_factor to 1 on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « android_webview/browser/hardware_renderer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/android/sys_utils.h" 9 #include "base/android/sys_utils.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 ui::WindowAndroidCompositor* compositor = 685 ui::WindowAndroidCompositor* compositor =
686 content_view_core_->GetWindowAndroid()->GetCompositor(); 686 content_view_core_->GetWindowAndroid()->GetCompositor();
687 DCHECK(compositor); 687 DCHECK(compositor);
688 DCHECK(frame_provider_); 688 DCHECK(frame_provider_);
689 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer = 689 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer =
690 cc::DelegatedRendererLayer::Create(frame_provider_); 690 cc::DelegatedRendererLayer::Create(frame_provider_);
691 delegated_layer->SetBounds(content_size_in_layer_); 691 delegated_layer->SetBounds(content_size_in_layer_);
692 delegated_layer->SetHideLayerAndSubtree(true); 692 delegated_layer->SetHideLayerAndSubtree(true);
693 delegated_layer->SetIsDrawable(true); 693 delegated_layer->SetIsDrawable(true);
694 delegated_layer->SetContentsOpaque(true); 694 delegated_layer->SetContentsOpaque(true);
695 gfx::Transform layer_scale( 695 gfx::Transform layer_scale(
jamesr 2014/06/12 23:00:04 you probably want to undo this change as well, rig
aelias_OOO_until_Jul13 2014/06/13 00:17:46 No, since https://codereview.chromium.org/33145300
jamesr 2014/06/13 00:27:53 Not that old - I added this scale 2 days ago.
aelias_OOO_until_Jul13 2014/06/13 00:36:07 Ah I see, removed.
696 device_scale_factor, 0.f, 0.f, device_scale_factor, 0.f, 0.f); 696 device_scale_factor, 0.f, 0.f, device_scale_factor, 0.f, 0.f);
697 delegated_layer->SetTransform(layer_scale); 697 delegated_layer->SetTransform(layer_scale);
698 compositor->AttachLayerForReadback(delegated_layer); 698 compositor->AttachLayerForReadback(delegated_layer);
699 699
700 readback_layer = delegated_layer; 700 readback_layer = delegated_layer;
701 request = cc::CopyOutputRequest::CreateRequest( 701 request = cc::CopyOutputRequest::CreateRequest(
702 base::Bind(&RenderWidgetHostViewAndroid:: 702 base::Bind(&RenderWidgetHostViewAndroid::
703 PrepareTextureCopyOutputResultForDelegatedReadback, 703 PrepareTextureCopyOutputResultForDelegatedReadback,
704 dst_size_in_pixel, 704 dst_size_in_pixel,
705 bitmap_config, 705 bitmap_config,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 resource_collection_->SetClient(NULL); 787 resource_collection_->SetClient(NULL);
788 if (resource_collection_->LoseAllResources()) 788 if (resource_collection_->LoseAllResources())
789 SendReturnedDelegatedResources(last_output_surface_id_); 789 SendReturnedDelegatedResources(last_output_surface_id_);
790 resource_collection_ = NULL; 790 resource_collection_ = NULL;
791 } 791 }
792 DestroyDelegatedContent(); 792 DestroyDelegatedContent();
793 793
794 last_output_surface_id_ = output_surface_id; 794 last_output_surface_id_ = output_surface_id;
795 } 795 }
796 796
797 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the
798 // renderer frame, assuming that the browser compositor will scale
799 // it back up to device scale. But on Android we put our browser layers in
800 // physical pixels and set our browser CC device_scale_factor to 1, so this
801 // suppresses the transform.
jamesr 2014/06/12 23:00:04 maybe include a link to the crbug about multiple m
aelias_OOO_until_Jul13 2014/06/13 00:17:46 crbug archeology didn't turn up anything, but I li
jamesr 2014/06/13 00:27:53 I was thinking of http://code.google.com/p/chromiu
aelias_OOO_until_Jul13 2014/06/13 00:36:07 OK, linked.
802 frame_data->device_scale_factor = 1.0f;
803
797 if (!has_content) { 804 if (!has_content) {
798 DestroyDelegatedContent(); 805 DestroyDelegatedContent();
799 } else { 806 } else {
800 if (!resource_collection_.get()) { 807 if (!resource_collection_.get()) {
801 resource_collection_ = new cc::DelegatedFrameResourceCollection; 808 resource_collection_ = new cc::DelegatedFrameResourceCollection;
802 resource_collection_->SetClient(this); 809 resource_collection_->SetClient(this);
803 } 810 }
804 if (!frame_provider_ || 811 if (!frame_provider_ ||
805 texture_size_in_layer_ != frame_provider_->frame_size()) { 812 texture_size_in_layer_ != frame_provider_->frame_size()) {
806 RemoveLayers(); 813 RemoveLayers();
807 frame_provider_ = new cc::DelegatedFrameProvider( 814 frame_provider_ = new cc::DelegatedFrameProvider(
808 resource_collection_.get(), frame_data.Pass()); 815 resource_collection_.get(), frame_data.Pass());
809 layer_ = cc::DelegatedRendererLayer::Create(frame_provider_); 816 layer_ = cc::DelegatedRendererLayer::Create(frame_provider_);
810 AttachLayers(); 817 AttachLayers();
811 } else { 818 } else {
812 frame_provider_->SetFrameData(frame_data.Pass()); 819 frame_provider_->SetFrameData(frame_data.Pass());
813 } 820 }
814 } 821 }
815 822
816 if (layer_.get()) { 823 if (layer_.get()) {
817 layer_->SetIsDrawable(true); 824 layer_->SetIsDrawable(true);
818 layer_->SetContentsOpaque(true); 825 layer_->SetContentsOpaque(true);
819 layer_->SetBounds(content_size_in_layer_); 826 layer_->SetBounds(content_size_in_layer_);
820 layer_->SetNeedsDisplay(); 827 layer_->SetNeedsDisplay();
821 // DelegatedRendererLayer scales the frame data from physical space to DIPs
822 // by inverting the frame's device scale factor, assuming that the browser
823 // compositor will map from DIPs back to physical pixels using its own
824 // device scale factor. However, the Android browser compositor always uses
825 // a device scale factor of 1.0, so we have to transform the delegated
826 // layer by the device scale to get it into the same physical pixel space as
827 // the rest of the UI.
828 const gfx::Display& display =
829 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
830 float device_scale_factor = display.device_scale_factor();
831 gfx::Transform layer_scale(
832 device_scale_factor, 0.f, 0.f, device_scale_factor, 0.f, 0.f);
833 layer_->SetTransform(layer_scale);
834 } 828 }
835 829
836 base::Closure ack_callback = 830 base::Closure ack_callback =
837 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, 831 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck,
838 weak_ptr_factory_.GetWeakPtr(), 832 weak_ptr_factory_.GetWeakPtr(),
839 output_surface_id); 833 output_surface_id);
840 834
841 ack_callbacks_.push(ack_callback); 835 ack_callbacks_.push(ack_callback);
842 if (host_->is_hidden()) 836 if (host_->is_hidden())
843 RunAckCallbacks(); 837 RunAckCallbacks();
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 results->availableRect = display.work_area(); 1443 results->availableRect = display.work_area();
1450 results->deviceScaleFactor = display.device_scale_factor(); 1444 results->deviceScaleFactor = display.device_scale_factor();
1451 results->orientationAngle = display.RotationAsDegree(); 1445 results->orientationAngle = display.RotationAsDegree();
1452 gfx::DeviceDisplayInfo info; 1446 gfx::DeviceDisplayInfo info;
1453 results->depth = info.GetBitsPerPixel(); 1447 results->depth = info.GetBitsPerPixel();
1454 results->depthPerComponent = info.GetBitsPerComponent(); 1448 results->depthPerComponent = info.GetBitsPerComponent();
1455 results->isMonochrome = (results->depthPerComponent == 0); 1449 results->isMonochrome = (results->depthPerComponent == 0);
1456 } 1450 }
1457 1451
1458 } // namespace content 1452 } // namespace content
OLDNEW
« no previous file with comments | « android_webview/browser/hardware_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698