| 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 b0968062b537cce780faf9f2eadadb23d4023736..b07762619088694594ff5af9b625563c77a632ef 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
|
| @@ -120,10 +120,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;
|
| @@ -133,7 +133,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_;
|
| @@ -141,9 +142,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;
|
| }
|
| @@ -154,8 +155,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(),
|
| @@ -173,7 +174,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());
|
| @@ -188,10 +189,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;
|
| @@ -221,7 +219,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()) {
|
| @@ -230,7 +228,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();
|
| }
|
| @@ -241,13 +239,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();
|
| uint32 sync_point = 0;
|
| if (result) {
|
| - GLHelper* gl_helper = GetPostReadbackGLHelper();
|
| + GLHelper* gl_helper = GetPostReadbackGLHelper(display_area);
|
| if (gl_helper)
|
| sync_point = gl_helper->InsertSyncPoint();
|
| }
|
| @@ -293,6 +292,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(
|
| @@ -903,12 +917,17 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
|
| layer->SetHideLayerAndSubtree(true);
|
| compositor->AttachLayerForReadback(layer);
|
|
|
| + const gfx::DeviceDisplayInfo& display_info =
|
| + content_view_core_window_android_->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(request.Pass());
|
| @@ -1546,9 +1565,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_) {
|
| + gfx::NativeView view_android = GetNativeView();
|
| +
|
| + const gfx::Display& display =
|
| + gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view_android);
|
| + const gfx::DeviceDisplayInfo& info =
|
| + content_view_core_window_android_->GetDeviceDisplayInfo();
|
| + DisplayInfoToScreenInfo(display, info, results);
|
| + } else {
|
| + GetDefaultScreenInfo(results);
|
| + }
|
| }
|
|
|
| bool RenderWidgetHostViewAndroid::GetScreenColorProfile(
|
| @@ -1933,10 +1961,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, result.Pass());
|
| + PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time,
|
| + callback, display_area, result.Pass());
|
| }
|
|
|
| // static
|
| @@ -1945,6 +1974,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));
|
| @@ -1960,7 +1990,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))
|
| @@ -1990,19 +2020,11 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
|
| ignore_result(scoped_callback_runner.Release());
|
|
|
| gl_helper->CropScaleReadbackAndCleanMailbox(
|
| - texture_mailbox.mailbox(),
|
| - texture_mailbox.sync_point(),
|
| - result->size(),
|
| - 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)),
|
| + texture_mailbox.mailbox(), texture_mailbox.sync_point(), result->size(),
|
| + 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), display_area),
|
| GLHelper::SCALER_QUALITY_GOOD);
|
| }
|
|
|
| @@ -2038,17 +2060,8 @@ void RenderWidgetHostViewBase::GetDefaultScreenInfo(
|
| blink::WebScreenInfo* results) {
|
| const gfx::Display& display =
|
| gfx::Screen::GetNativeScreen()->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
|
|
|