Index: content/browser/renderer_host/render_widget_host_view_android.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
index ddb0f0ce1fb840d1ed944fc0e7a18a68f6385e85..23131524f50b2d481dbf02be2e51f50c09991b06 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_android.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
@@ -119,10 +119,10 @@ static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; |
class GLHelperHolder |
: public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
public: |
- static GLHelperHolder* Create(); |
+ static GLHelperHolder* Create(size_t display_area); |
~GLHelperHolder() override; |
- void Initialize(); |
+ void Initialize(size_t display_area); |
// WebGraphicsContextLostCallback implementation. |
void onContextLost() override; |
@@ -132,7 +132,8 @@ class GLHelperHolder |
private: |
GLHelperHolder(); |
- static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); |
+ static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D( |
+ size_t display_area); |
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; |
scoped_ptr<GLHelper> gl_helper_; |
@@ -140,9 +141,9 @@ class GLHelperHolder |
DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); |
}; |
-GLHelperHolder* GLHelperHolder::Create() { |
+GLHelperHolder* GLHelperHolder::Create(size_t display_area) { |
GLHelperHolder* holder = new GLHelperHolder; |
- holder->Initialize(); |
+ holder->Initialize(display_area); |
return holder; |
} |
@@ -153,8 +154,8 @@ GLHelperHolder::GLHelperHolder() { |
GLHelperHolder::~GLHelperHolder() { |
} |
-void GLHelperHolder::Initialize() { |
- context_ = CreateContext3D(); |
+void GLHelperHolder::Initialize(size_t display_area) { |
+ context_ = CreateContext3D(display_area); |
if (context_) { |
context_->setContextLostCallback(this); |
gl_helper_.reset(new GLHelper(context_->GetImplementation(), |
@@ -172,7 +173,7 @@ void GLHelperHolder::onContextLost() { |
} |
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
-GLHelperHolder::CreateContext3D() { |
+GLHelperHolder::CreateContext3D(size_t display_area) { |
BrowserGpuChannelHostFactory* factory = |
BrowserGpuChannelHostFactory::instance(); |
scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); |
@@ -187,10 +188,7 @@ GLHelperHolder::CreateContext3D() { |
attrs.shareResources = true; |
GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); |
static const size_t kBytesPerPixel = 4; |
- gfx::DeviceDisplayInfo display_info; |
- size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() * |
- display_info.GetDisplayWidth() * |
- kBytesPerPixel; |
+ size_t full_screen_texture_size_in_bytes = display_area * kBytesPerPixel; |
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
limits.command_buffer_size = 64 * 1024; |
limits.start_transfer_buffer_size = 64 * 1024; |
@@ -220,7 +218,7 @@ GLHelperHolder::CreateContext3D() { |
// This can only be used for readback postprocessing. It may return null if the |
// channel was lost and not reestablished yet. |
-GLHelper* GetPostReadbackGLHelper() { |
+GLHelper* GetPostReadbackGLHelper(size_t display_area) { |
static GLHelperHolder* g_readback_helper_holder = nullptr; |
if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { |
@@ -229,7 +227,7 @@ GLHelper* GetPostReadbackGLHelper() { |
} |
if (!g_readback_helper_holder) |
- g_readback_helper_holder = GLHelperHolder::Create(); |
+ g_readback_helper_holder = GLHelperHolder::Create(display_area); |
return g_readback_helper_holder->GetGLHelper(); |
} |
@@ -240,13 +238,14 @@ void CopyFromCompositingSurfaceFinished( |
scoped_ptr<SkBitmap> bitmap, |
const base::TimeTicks& start_time, |
scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
+ size_t display_area, |
bool result) { |
TRACE_EVENT0( |
"cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); |
bitmap_pixels_lock.reset(); |
gpu::SyncToken sync_token; |
if (result) { |
- GLHelper* gl_helper = GetPostReadbackGLHelper(); |
+ GLHelper* gl_helper = GetPostReadbackGLHelper(display_area); |
if (gl_helper) |
gl_helper->GenerateSyncToken(&sync_token); |
} |
@@ -292,6 +291,21 @@ gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
return rect; |
} |
+void DisplayInfoToScreenInfo(const gfx::Display& display, |
+ const gfx::DeviceDisplayInfo& info, |
+ blink::WebScreenInfo* results) { |
+ results->rect = display.bounds(); |
+ // TODO(husky): Remove any system controls from availableRect. |
+ results->availableRect = display.work_area(); |
+ results->deviceScaleFactor = display.device_scale_factor(); |
+ results->orientationAngle = display.RotationAsDegree(); |
+ results->orientationType = |
+ RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
+ results->depth = info.GetBitsPerPixel(); |
+ results->depthPerComponent = info.GetBitsPerComponent(); |
+ results->isMonochrome = (results->depthPerComponent == 0); |
+} |
+ |
} // anonymous namespace |
RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( |
@@ -906,12 +920,17 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
layer->SetHideLayerAndSubtree(true); |
compositor->AttachLayerForReadback(layer); |
+ const gfx::DeviceDisplayInfo& display_info = |
+ content_view_core_->GetWindowAndroid()->GetDeviceDisplayInfo(); |
+ size_t display_area = |
+ display_info.GetDisplayHeight() * display_info.GetDisplayWidth(); |
+ |
readback_layer = layer; |
request = cc::CopyOutputRequest::CreateRequest( |
base::Bind(&RenderWidgetHostViewAndroid:: |
PrepareTextureCopyOutputResultForDelegatedReadback, |
dst_size_in_pixel, preferred_color_type, start_time, |
- readback_layer, callback)); |
+ readback_layer, callback, display_area)); |
if (!src_subrect_in_pixel.IsEmpty()) |
request->set_area(src_subrect_in_pixel); |
readback_layer->RequestCopyOfOutput(std::move(request)); |
@@ -1514,9 +1533,18 @@ bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( |
return false; |
} |
-void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { |
- // ScreenInfo isn't tied to the widget on Android. Always return the default. |
- RenderWidgetHostViewBase::GetDefaultScreenInfo(result); |
+void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* results) { |
+ if (content_view_core_) { |
no sievers
2016/02/27 01:11:52
I'm wondering if it's worth plumbing all this info
boliu
2016/02/27 01:30:56
It's also used to determine stuff like screen dens
no sievers
2016/02/29 18:16:03
The point was: If this is for multi-display, then
gsennton
2016/04/25 18:55:58
I experimented a bit by setting different device s
|
+ gfx::NativeView view_android = GetNativeView(); |
+ |
+ const gfx::Display& display = |
+ gfx::Screen::GetScreen()->GetDisplayNearestWindow(view_android); |
+ const gfx::DeviceDisplayInfo& info = |
+ content_view_core_->GetWindowAndroid()->GetDeviceDisplayInfo(); |
+ DisplayInfoToScreenInfo(display, info, results); |
+ } else { |
+ GetDefaultScreenInfo(results); |
+ } |
} |
bool RenderWidgetHostViewAndroid::GetScreenColorProfile( |
@@ -1938,10 +1966,11 @@ void RenderWidgetHostViewAndroid:: |
const base::TimeTicks& start_time, |
scoped_refptr<cc::Layer> readback_layer, |
const ReadbackRequestCallback& callback, |
+ size_t display_area, |
scoped_ptr<cc::CopyOutputResult> result) { |
readback_layer->RemoveFromParent(); |
PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time, |
- callback, std::move(result)); |
+ callback, display_area, std::move(result)); |
} |
// TODO(wjmaclean): There is significant overlap between |
@@ -1955,6 +1984,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
SkColorType color_type, |
const base::TimeTicks& start_time, |
const ReadbackRequestCallback& callback, |
+ size_t display_area, |
scoped_ptr<cc::CopyOutputResult> result) { |
base::ScopedClosureRunner scoped_callback_runner( |
base::Bind(callback, SkBitmap(), READBACK_FAILED)); |
@@ -1970,7 +2000,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
else |
output_size_in_pixel = dst_size_in_pixel; |
- GLHelper* gl_helper = GetPostReadbackGLHelper(); |
+ GLHelper* gl_helper = GetPostReadbackGLHelper(display_area); |
if (!gl_helper) |
return; |
if (!gl_helper->IsReadbackConfigSupported(color_type)) |
@@ -2004,7 +2034,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, |
base::Bind(&CopyFromCompositingSurfaceFinished, callback, |
base::Passed(&release_callback), base::Passed(&bitmap), |
- start_time, base::Passed(&bitmap_pixels_lock)), |
+ start_time, base::Passed(&bitmap_pixels_lock), display_area), |
GLHelper::SCALER_QUALITY_GOOD); |
} |
@@ -2039,17 +2069,8 @@ void RenderWidgetHostViewAndroid::OnStylusSelectTap(base::TimeTicks time, |
void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
blink::WebScreenInfo* results) { |
const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
- results->rect = display.bounds(); |
- // TODO(husky): Remove any system controls from availableRect. |
- results->availableRect = display.work_area(); |
- results->deviceScaleFactor = display.device_scale_factor(); |
- results->orientationAngle = display.RotationAsDegree(); |
- results->orientationType = |
- RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
gfx::DeviceDisplayInfo info; |
- results->depth = info.GetBitsPerPixel(); |
- results->depthPerComponent = info.GetBitsPerComponent(); |
- results->isMonochrome = (results->depthPerComponent == 0); |
+ DisplayInfoToScreenInfo(display, info, results); |
} |
} // namespace content |