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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 1144333004: Make WebView work for external displays (over Presentations). Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add single global polling in ScreenOrientationListener Created 5 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 side-by-side diff with in-line comments
Download patch
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 abdb9eba431b6d22f2f20412fe2d875069cc7470..59638311d16f8072303ef14562228462cd8e0663 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -125,10 +125,10 @@ void SendImeEventAck(RenderWidgetHostImpl* host) {
class GLHelperHolder
: public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
public:
- static GLHelperHolder* Create();
+ static GLHelperHolder* Create(gfx::NativeWindow nativeWindow);
jdduke (slow) 2015/07/15 16:03:06 native_window everywhere, though if these classes
~GLHelperHolder() override;
- void Initialize();
+ void Initialize(gfx::NativeWindow nativeWindow);
// WebGraphicsContextLostCallback implementation.
void onContextLost() override;
@@ -138,7 +138,8 @@ class GLHelperHolder
private:
GLHelperHolder();
- static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D();
+ static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(
+ gfx::NativeWindow nativeWindow);
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
scoped_ptr<GLHelper> gl_helper_;
@@ -146,9 +147,9 @@ class GLHelperHolder
DISALLOW_COPY_AND_ASSIGN(GLHelperHolder);
};
-GLHelperHolder* GLHelperHolder::Create() {
+GLHelperHolder* GLHelperHolder::Create(gfx::NativeWindow nativeWindow) {
GLHelperHolder* holder = new GLHelperHolder;
- holder->Initialize();
+ holder->Initialize(nativeWindow);
return holder;
}
@@ -159,8 +160,8 @@ GLHelperHolder::GLHelperHolder() {
GLHelperHolder::~GLHelperHolder() {
}
-void GLHelperHolder::Initialize() {
- context_ = CreateContext3D();
+void GLHelperHolder::Initialize(gfx::NativeWindow nativeWindow) {
+ context_ = CreateContext3D(nativeWindow);
if (context_) {
context_->setContextLostCallback(this);
gl_helper_.reset(new GLHelper(context_->GetImplementation(),
@@ -178,7 +179,7 @@ void GLHelperHolder::onContextLost() {
}
scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
-GLHelperHolder::CreateContext3D() {
+GLHelperHolder::CreateContext3D(gfx::NativeWindow nativeWindow) {
BrowserGpuChannelHostFactory* factory =
BrowserGpuChannelHostFactory::instance();
scoped_refptr<GpuChannelHost> gpu_channel_host(factory->GetGpuChannel());
@@ -193,7 +194,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 =
+ nativeWindow->GetDeviceDisplayInfo();
size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
display_info.GetDisplayWidth() *
kBytesPerPixel;
@@ -226,7 +228,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 nativeWindow) {
static GLHelperHolder* g_readback_helper_holder = nullptr;
if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) {
@@ -235,7 +237,7 @@ GLHelper* GetPostReadbackGLHelper() {
}
if (!g_readback_helper_holder)
- g_readback_helper_holder = GLHelperHolder::Create();
+ g_readback_helper_holder = GLHelperHolder::Create(nativeWindow);
return g_readback_helper_holder->GetGLHelper();
}
@@ -246,13 +248,14 @@ void CopyFromCompositingSurfaceFinished(
scoped_ptr<SkBitmap> bitmap,
const base::TimeTicks& start_time,
scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
+ gfx::NativeWindow nativeWindow,
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(nativeWindow);
if (gl_helper)
sync_point = gl_helper->InsertSyncPoint();
}
@@ -305,6 +308,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(
@@ -929,7 +947,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());
@@ -1545,9 +1563,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);
+ }
}
// TODO(jrg): Find out the implications and answer correctly here,
@@ -1925,10 +1952,11 @@ void RenderWidgetHostViewAndroid::
const base::TimeTicks& start_time,
scoped_refptr<cc::Layer> readback_layer,
ReadbackRequestCallback& callback,
+ gfx::NativeWindow nativeWindow,
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, nativeWindow, result.Pass());
}
// static
@@ -1937,6 +1965,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
SkColorType color_type,
const base::TimeTicks& start_time,
ReadbackRequestCallback& callback,
+ gfx::NativeWindow nativeWindow,
scoped_ptr<cc::CopyOutputResult> result) {
base::ScopedClosureRunner scoped_callback_runner(
base::Bind(callback, SkBitmap(), READBACK_FAILED));
@@ -1952,7 +1981,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
else
output_size_in_pixel = dst_size_in_pixel;
- GLHelper* gl_helper = GetPostReadbackGLHelper();
+ GLHelper* gl_helper = GetPostReadbackGLHelper(nativeWindow);
if (!gl_helper)
return;
if (!gl_helper->IsReadbackConfigSupported(color_type))
@@ -1982,19 +2011,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), nativeWindow),
GLHelper::SCALER_QUALITY_GOOD);
}
@@ -2030,17 +2051,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

Powered by Google App Engine
This is Rietveld 408576698