Chromium Code Reviews| 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..af23281f19f45668154406b39ce4996cb7536af6 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(gfx::NativeWindow native_window); |
| ~GLHelperHolder() override; |
| - void Initialize(); |
| + void Initialize(gfx::NativeWindow native_window); |
| // WebGraphicsContextLostCallback implementation. |
| void onContextLost() override; |
| @@ -133,7 +133,8 @@ class GLHelperHolder |
| private: |
| GLHelperHolder(); |
| - static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); |
| + static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D( |
| + gfx::NativeWindow native_window); |
| 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(gfx::NativeWindow native_window) { |
| GLHelperHolder* holder = new GLHelperHolder; |
| - holder->Initialize(); |
| + holder->Initialize(native_window); |
| return holder; |
| } |
| @@ -154,8 +155,8 @@ GLHelperHolder::GLHelperHolder() { |
| GLHelperHolder::~GLHelperHolder() { |
| } |
| -void GLHelperHolder::Initialize() { |
| - context_ = CreateContext3D(); |
| +void GLHelperHolder::Initialize(gfx::NativeWindow native_window) { |
| + context_ = CreateContext3D(native_window); |
| 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(gfx::NativeWindow native_window) { |
| BrowserGpuChannelHostFactory* factory = |
| BrowserGpuChannelHostFactory::instance(); |
| scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); |
| @@ -188,7 +189,8 @@ GLHelperHolder::CreateContext3D() { |
| attrs.shareResources = true; |
| GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); |
| static const size_t kBytesPerPixel = 4; |
| - gfx::DeviceDisplayInfo display_info; |
| + const gfx::DeviceDisplayInfo& display_info = |
| + native_window->GetDeviceDisplayInfo(); |
| size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() * |
| display_info.GetDisplayWidth() * |
| kBytesPerPixel; |
| @@ -221,7 +223,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(gfx::NativeWindow native_window) { |
| static GLHelperHolder* g_readback_helper_holder = nullptr; |
| if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { |
| @@ -230,7 +232,7 @@ GLHelper* GetPostReadbackGLHelper() { |
| } |
| if (!g_readback_helper_holder) |
| - g_readback_helper_holder = GLHelperHolder::Create(); |
| + g_readback_helper_holder = GLHelperHolder::Create(native_window); |
| return g_readback_helper_holder->GetGLHelper(); |
| } |
| @@ -241,13 +243,14 @@ void CopyFromCompositingSurfaceFinished( |
| scoped_ptr<SkBitmap> bitmap, |
| const base::TimeTicks& start_time, |
| scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| + gfx::NativeWindow native_window, |
| 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(native_window); |
| if (gl_helper) |
| sync_point = gl_helper->InsertSyncPoint(); |
| } |
| @@ -293,6 +296,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( |
| @@ -908,7 +926,7 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
| base::Bind(&RenderWidgetHostViewAndroid:: |
| PrepareTextureCopyOutputResultForDelegatedReadback, |
| dst_size_in_pixel, preferred_color_type, start_time, |
| - readback_layer, callback)); |
| + readback_layer, callback, content_view_core_window_android_)); |
| if (!src_subrect_in_pixel.IsEmpty()) |
| request->set_area(src_subrect_in_pixel); |
| readback_layer->RequestCopyOfOutput(request.Pass()); |
| @@ -1546,9 +1564,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 +1960,11 @@ void RenderWidgetHostViewAndroid:: |
| const base::TimeTicks& start_time, |
| scoped_refptr<cc::Layer> readback_layer, |
| const ReadbackRequestCallback& callback, |
| + gfx::NativeWindow native_window, |
| 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, native_window, result.Pass()); |
| } |
| // static |
| @@ -1945,6 +1973,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| SkColorType color_type, |
| const base::TimeTicks& start_time, |
| const ReadbackRequestCallback& callback, |
| + gfx::NativeWindow native_window, |
| scoped_ptr<cc::CopyOutputResult> result) { |
| base::ScopedClosureRunner scoped_callback_runner( |
| base::Bind(callback, SkBitmap(), READBACK_FAILED)); |
| @@ -1960,7 +1989,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| else |
| output_size_in_pixel = dst_size_in_pixel; |
| - GLHelper* gl_helper = GetPostReadbackGLHelper(); |
| + GLHelper* gl_helper = GetPostReadbackGLHelper(native_window); |
| if (!gl_helper) |
| return; |
| if (!gl_helper->IsReadbackConfigSupported(color_type)) |
| @@ -1990,19 +2019,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), native_window), |
|
jdduke (slow)
2015/10/22 15:37:05
sievers@ is it safe to bind this pointer? I know W
no sievers
2015/10/26 20:42:25
No this is actually not safe, since the pointer is
gsennton
2015/10/27 11:40:24
Since all we need from the window_android pointer
|
| GLHelper::SCALER_QUALITY_GOOD); |
| } |
| @@ -2038,17 +2059,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 |