summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 01:48:12 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 01:48:12 +0000
commit28599f4802c403c4d362f734ba37f81b552be977 (patch)
treec6ff86f1d689da8ab25d29bbe55722976baa37ed /content/browser/renderer_host
parent8ca4c95564702a77d3d149e436bc7a3ae9a08df1 (diff)
downloadchromium_src-28599f4802c403c4d362f734ba37f81b552be977.zip
chromium_src-28599f4802c403c4d362f734ba37f81b552be977.tar.gz
chromium_src-28599f4802c403c4d362f734ba37f81b552be977.tar.bz2
Makes the browser send pixels to the GPU process where it should.
This patch fixes the places where we will be sending DIP to the GPU process but should be sending pixels instead to the GPU process once https://bugs.webkit.org/show_bug.cgi?id=86051 lands. This patch reverts: http://codereview.chromium.org/127553/ http://codereview.chromium.org/10332077/ Bug=127455, 114677 Test=Manual SchedulePaintInRect is called with parameters in DIP TBR=piman@chromium.org,sky@chromium.org,jamesr@chromium.org Review URL: https://chromiumcodereview.appspot.com/10411086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host')
-rw-r--r--content/browser/renderer_host/dip_util.cc59
-rw-r--r--content/browser/renderer_host/dip_util.h40
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc71
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h8
4 files changed, 147 insertions, 31 deletions
diff --git a/content/browser/renderer_host/dip_util.cc b/content/browser/renderer_host/dip_util.cc
new file mode 100644
index 0000000..075c3c3
--- /dev/null
+++ b/content/browser/renderer_host/dip_util.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/dip_util.h"
+
+#include "content/public/browser/render_widget_host_view.h"
+#include "ui/gfx/monitor.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/screen.h"
+#include "ui/gfx/size.h"
+
+namespace content {
+
+float GetDIPScaleFactor(const RenderWidgetHostView* view) {
+ if (gfx::Screen::IsDIPEnabled()) {
+ gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow(
+ view ? view->GetNativeView() : NULL);
+ return monitor.device_scale_factor();
+ }
+ return 1.0f;
+}
+
+gfx::Point ConvertPointToDIP(const RenderWidgetHostView* view,
+ const gfx::Point& point_in_pixel) {
+ return point_in_pixel.Scale(1.0f / GetDIPScaleFactor(view));
+}
+
+gfx::Size ConvertSizeToDIP(const RenderWidgetHostView* view,
+ const gfx::Size& size_in_pixel) {
+ return size_in_pixel.Scale(1.0f / GetDIPScaleFactor(view));
+}
+
+gfx::Rect ConvertRectToDIP(const RenderWidgetHostView* view,
+ const gfx::Rect& rect_in_pixel) {
+ float scale = 1.0f / GetDIPScaleFactor(view);
+ return gfx::Rect(rect_in_pixel.origin().Scale(scale),
+ rect_in_pixel.size().Scale(scale));
+}
+
+gfx::Point ConvertPointToPixel(const RenderWidgetHostView* view,
+ const gfx::Point& point_in_dip) {
+ return point_in_dip.Scale(GetDIPScaleFactor(view));
+}
+
+gfx::Size ConvertSizeToPixel(const RenderWidgetHostView* view,
+ const gfx::Size& size_in_dip) {
+ return size_in_dip.Scale(GetDIPScaleFactor(view));
+}
+
+gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view,
+ const gfx::Rect& rect_in_dip) {
+ float scale = GetDIPScaleFactor(view);
+ return gfx::Rect(rect_in_dip.origin().Scale(scale),
+ rect_in_dip.size().Scale(scale));
+}
+
+} // namespace content
diff --git a/content/browser/renderer_host/dip_util.h b/content/browser/renderer_host/dip_util.h
new file mode 100644
index 0000000..ac9ba9d
--- /dev/null
+++ b/content/browser/renderer_host/dip_util.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_DIP_UTIL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_DIP_UTIL_H_
+#pragma once
+
+#include "content/common/content_export.h"
+
+namespace gfx {
+class Point;
+class Rect;
+class Size;
+} // namespace gfx
+
+namespace content {
+class RenderWidgetHostView;
+
+// Returns scale factor used to convert from DIP to pixel coordinate systems.
+// Returns 1.0 if DIP is not enabled.
+CONTENT_EXPORT float GetDIPScaleFactor(const RenderWidgetHostView* view);
+
+// Utility functions that convert point/size/rect between DIP and pixel
+// coordinate system.
+CONTENT_EXPORT gfx::Point ConvertPointToDIP(const RenderWidgetHostView* view,
+ const gfx::Point& point_in_pixel);
+CONTENT_EXPORT gfx::Size ConvertSizeToDIP(const RenderWidgetHostView* view,
+ const gfx::Size& size_in_pixel);
+CONTENT_EXPORT gfx::Rect ConvertRectToDIP(const RenderWidgetHostView* view,
+ const gfx::Rect& rect_in_pixel);
+CONTENT_EXPORT gfx::Point ConvertPointToPixel(const RenderWidgetHostView* view,
+ const gfx::Point& point_in_dip);
+CONTENT_EXPORT gfx::Size ConvertSizeToPixel(const RenderWidgetHostView* view,
+ const gfx::Size& size_in_dip);
+CONTENT_EXPORT gfx::Rect ConvertRectToPixel(const RenderWidgetHostView* view,
+ const gfx::Rect& rect_in_dip);
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_DIP_UTIL_H_
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index a61b5fa..5bb4f3b 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -12,6 +12,7 @@
#include "base/message_loop.h"
#include "base/string_number_conversions.h"
#include "content/browser/renderer_host/backing_store_skia.h"
+#include "content/browser/renderer_host/dip_util.h"
#include "content/browser/renderer_host/image_transport_client.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/web_input_event_aura.h"
@@ -269,9 +270,9 @@ void RenderWidgetHostViewAura::InitAsFullscreen(
window_->SetName("RenderWidgetHostViewAura");
window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
window_->SetParent(NULL);
- // Don't scale the canvas on high density screen because
+ // Don't scale the contents on high density screen because
// the renderer takes care of it.
- window_->layer()->set_scale_canvas(false);
+ window_->layer()->set_scale_content(false);
Show();
Focus();
}
@@ -452,7 +453,9 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface(
if (!container)
return;
- if (!output->initialize(size.width(), size.height(), true))
+ gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size);
+ if (!output->initialize(
+ size_in_pixel.width(), size_in_pixel.height(), true))
return;
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
@@ -465,7 +468,7 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface(
scoped_callback_runner.Release();
gl_helper->CopyTextureTo(container->texture_id(),
container->size(),
- size,
+ size_in_pixel,
addr,
callback);
}
@@ -478,6 +481,13 @@ void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
// the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
// fewer inconsistent temporary states.
needs_update_texture_ = true;
+
+ // Don't scale contents on high density screen when content is accelerated
+ // because renderer takes care of it.
+ // TODO(pkotwicz): Implement DIP backing store such that renderer always
+ // scales web contents.
+ window_->layer()->set_scale_content(
+ !host_->is_accelerated_compositing_active());
}
void RenderWidgetHostViewAura::UpdateExternalTexture() {
@@ -497,7 +507,9 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() {
typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
ResizeLockList::iterator it = resize_locks_.begin();
while (it != resize_locks_.end()) {
- if ((*it)->expected_size() == container->size())
+ gfx::Size container_size = content::ConvertSizeToDIP(this,
+ container->size());
+ if ((*it)->expected_size() == container_size)
break;
++it;
}
@@ -529,19 +541,22 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() {
}
void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
- const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
+ const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
int gpu_host_id) {
- current_surface_ = params.surface_handle;
+ current_surface_ = params_in_pixel.surface_handle;
UpdateExternalTexture();
ui::Compositor* compositor = GetCompositor();
if (!compositor) {
// We have no compositor, so we have no way to display the surface.
// Must still send the ACK.
- RenderWidgetHostImpl::AcknowledgeSwapBuffers(params.route_id, gpu_host_id);
+ RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id,
+ gpu_host_id);
} else {
- gfx::Size surface_size =
- image_transport_clients_[params.surface_handle]->size();
+ gfx::Size surface_size_in_pixel =
+ image_transport_clients_[params_in_pixel.surface_handle]->size();
+ gfx::Size surface_size = content::ConvertSizeToDIP(this,
+ surface_size_in_pixel);
window_->SchedulePaintInRect(gfx::Rect(surface_size));
if (!resize_locks_.empty() && !compositor->DrawPending()) {
@@ -550,12 +565,12 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
// OnCompositingEnded(), because out-of-order execution in the GPU process
// might corrupt the "front buffer" for the currently issued frame.
RenderWidgetHostImpl::AcknowledgeSwapBuffers(
- params.route_id, gpu_host_id);
+ params_in_pixel.route_id, gpu_host_id);
} else {
// Add sending an ACK to the list of things to do OnCompositingEnded
on_compositing_ended_callbacks_.push_back(
base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
- params.route_id, gpu_host_id));
+ params_in_pixel.route_id, gpu_host_id));
if (!compositor->HasObserver(this))
compositor->AddObserver(this);
}
@@ -563,9 +578,9 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
}
void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
- const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
+ const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
int gpu_host_id) {
- current_surface_ = params.surface_handle;
+ current_surface_ = params_in_pixel.surface_handle;
UpdateExternalTexture();
ui::Compositor* compositor = GetCompositor();
@@ -573,18 +588,20 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
// We have no compositor, so we have no way to display the surface
// Must still send the ACK
RenderWidgetHostImpl::AcknowledgePostSubBuffer(
- params.route_id, gpu_host_id);
+ params_in_pixel.route_id, gpu_host_id);
} else {
- gfx::Size surface_size =
- image_transport_clients_[params.surface_handle]->size();
+ gfx::Size surface_size_in_pixel =
+ image_transport_clients_[params_in_pixel.surface_handle]->size();
// Co-ordinates come in OpenGL co-ordinate space.
// We need to convert to layer space.
- window_->SchedulePaintInRect(gfx::Rect(
- params.x,
- surface_size.height() - params.y - params.height,
- params.width,
- params.height));
+ gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect(
+ params_in_pixel.x,
+ surface_size_in_pixel.height() - params_in_pixel.y -
+ params_in_pixel.height,
+ params_in_pixel.width,
+ params_in_pixel.height));
+ window_->SchedulePaintInRect(rect_to_paint);
if (!resize_locks_.empty() && !compositor->DrawPending()) {
// If we are waiting for the resize, fast-track the ACK.
@@ -592,12 +609,12 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
// OnCompositingEnded(), because out-of-order execution in the GPU process
// might corrupt the "front buffer" for the currently issued frame.
RenderWidgetHostImpl::AcknowledgePostSubBuffer(
- params.route_id, gpu_host_id);
+ params_in_pixel.route_id, gpu_host_id);
} else {
// Add sending an ACK to the list of things to do OnCompositingEnded
on_compositing_ended_callbacks_.push_back(
base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer,
- params.route_id, gpu_host_id));
+ params_in_pixel.route_id, gpu_host_id));
if (!compositor->HasObserver(this))
compositor->AddObserver(this);
}
@@ -616,13 +633,13 @@ bool RenderWidgetHostViewAura::HasAcceleratedSurface(
}
void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
- int32 width,
- int32 height,
+ int32 width_in_pixel,
+ int32 height_in_pixel,
uint64* surface_handle,
TransportDIB::Handle* shm_handle) {
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient(
- gfx::Size(width, height), surface_handle));
+ gfx::Size(width_in_pixel, height_in_pixel), surface_handle));
if (!surface) {
LOG(ERROR) << "Failed to create ImageTransportClient";
return;
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index 395b8b8..3e1cdfe 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -99,16 +99,16 @@ class RenderWidgetHostViewAura
base::Callback<void(bool)> callback) OVERRIDE;
virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
virtual void AcceleratedSurfaceBuffersSwapped(
- const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
+ const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
int gpu_host_id) OVERRIDE;
virtual void AcceleratedSurfacePostSubBuffer(
- const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
+ const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
int gpu_host_id) OVERRIDE;
virtual void AcceleratedSurfaceSuspend() OVERRIDE;
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
virtual void AcceleratedSurfaceNew(
- int32 width,
- int32 height,
+ int32 width_in_pixel,
+ int32 height_in_pixel,
uint64* surface_id,
TransportDIB::Handle* surface_handle) OVERRIDE;
virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE;