New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 626788 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jul 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 626764



Sign in to add a comment

Android: Remove ContentViewCore::GetDpiScale()

Project Member Reported by siev...@chromium.org, Jul 8 2016

Issue description

There are only 3 call sites I can see:

1) RenderWidgetHostViewAndroid::CreateDrawable()
2) OverscrollControllerAndroid::OverscrollControllerAndroid()
3) PopupTouchHandleDrawable::Create()

That means that actually all of these are invoked from RenderWidgetHostViewAndroid.

@gsennton: What's the best way to do this since RWHVA can already get to all the necessary information? And also what's correct in terms of supporting multiple displays?

Without changing anything functionally I guess |ContentViewCoreImpl::dpi_scale_| could just move into RWHVA.
 
I updated  crbug.com/598880  to try to clarify this. I would like to use the Screen API to fetch display information (which is also what ui::GetScaleFactorForNativeView uses), which means that we need to reach information about the current display through ViewAndroid.

So for any of these call sites to just get the appropriate DPI scale we could just call ui::GetScaleFactorForNativeView(RWHVA.GetNativeView()) since this will tie the DPI fetching to the ViewAndroid API rather than directly to ContentViewCore (and potentially store this value in RWHVA as long as RWHVA can't be updated/reused to target another display).
Currently such a call will just result in fetching the DPI scale for the primary display (but this will change when we change the implementation of ScreenAndroid).
> (and potentially store this value in RWHVA as long as RWHVA can't be updated/reused to target another display).

But what if a view moves from one display to another?

I feel like this is all just current state depending on where the view is currently shown or what it is attached to (also see custom tabs which allow moving to different activities). So better would be to just always dynamically query the view for its *current* window and display/screen.
Sure, dynamically querying the view sounds good to me.

How do custom tabs work, I assume they need to recreate an ActivityWindowAndroid
 when they move to different Activities?
Yes, and then they call ContentViewCoreImpl::UpdateWindowAndroid().

After https://codereview.chromium.org/2122403002/ lands I guess I can remove |ContentViewCore::window_android_| and that can be done through ViewAndroid::GetWindowAndroid() instead.

There are some observer interfaces also so that when the WindowAndroid changes the listeners/observers have to re-register themselves with the new Window. (Maybe that can be simplified a bit when that trickles through ViewAndroid.)
Cc: yus...@chromium.org
Owner: gsennton@chromium.org
Can I assign this to you to implement GetDisplayNearestWindow() accordingly in screen_android.cc?

It sounds like this is basically what you were doing anyways, looking at https://codereview.chromium.org/1409833004/diff/140001/ui/android/window_android.h which exposes the display info there.


Sure, though these code changes should be possible without a proper implementation of GetDisplayNearestWindow(), right? I.e. just like it is implemented right now - returning GetPrimaryDisplay(). (though the DPI of CVC will then be that of the primary display until we update the implementation of GetDisplayNearestWindow)

The CL you refer to in #6 is old and we are moving towards removing DeviceDisplayInfo instead (see https://docs.google.com/a/google.com/document/d/1fJDGn3wSzKtm7HSkSatWRXgkAZqj95iBJ20gtsZhqrc/edit?usp=sharing).
True, we don't have to change it to move it out of CVC into RWHV.

Besides the implementation behind it (supporting more than the default display), the other thing that we should change is to not cache |dpi_scale_| or anything else in CVC/RWHV (well, or update it when the display changes at least). But your doc seems to address that also: IIUC the caching could be handled inside DisplayHandler, so that we can just always call GetScaleFactorForNativeView(ViewAndroid*) and it would be cheap.



Yepp, the idea would be to cache it in a DisplayHandler. Though, at the moment there is a similar cache available when using DeviceDisplayInfo (only for the primary display) so I'm not sure why we are caching dpi_scale in CVC at all.. will have a look.
Hm, content_view_core_impl.dpi_scale_ was added in
https://chromiumcodereview.appspot.com/11099007
where it was set in the following way:

if (!gfx::Screen::IsDIPEnabled()) {
  dpi_scale_ = 1;
} else {
 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo());
 dpi_scale_ = device_info->GetDPIScale();
}

I think it has just stayed there since then, and that it's not necessary since IsDIPEnabled is no longer used?
A couple of notes here:
1. overscroll_controller_android and popup_touch_handle_drawable also store their own dpi_scale_ variables (rather than storing the content_view_core object itself). Maybe these should hold a reference to a ViewAndroid instead (to be able to change/fetch the dpi_scale dynamically)?
2. Both the OverscrollControllerAndroid::OverscrollControllerAndroid() and PopupTouchHandleDrawable::Create() calls take a ContentViewCore for other reasons than just GetDpiScale - i.e. to initialize the Java side or because ConventViewCoreImpl is an OverscrollRefreshHandler (actually OverscrollControllerAndroid takes a ContentViewCoreImpl while PopupTouchHandleDrawable only takes a ContentViewCore).
Project Member

Comment 12 by bugdroid1@chromium.org, Jul 14 2016

Status: Fixed (was: Available)

Sign in to add a comment