Commit 0383fcc8 authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Revert 138415 - 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

TBR=pkotwicz@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10383297

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138419 0039d316-1c4b-4281-b951-d872f2087c98
parent deb96b4e
// 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
// 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_
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "content/browser/renderer_host/backing_store_skia.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/image_transport_client.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/web_input_event_aura.h" #include "content/browser/renderer_host/web_input_event_aura.h"
...@@ -270,9 +269,9 @@ void RenderWidgetHostViewAura::InitAsFullscreen( ...@@ -270,9 +269,9 @@ void RenderWidgetHostViewAura::InitAsFullscreen(
window_->SetName("RenderWidgetHostViewAura"); window_->SetName("RenderWidgetHostViewAura");
window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
window_->SetParent(NULL); window_->SetParent(NULL);
// Don't scale the contents on high density screen because // Don't scale the canvas on high density screen because
// the renderer takes care of it. // the renderer takes care of it.
window_->layer()->set_scale_content(false); window_->layer()->set_scale_canvas(false);
Show(); Show();
Focus(); Focus();
} }
...@@ -453,9 +452,7 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface( ...@@ -453,9 +452,7 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface(
if (!container) if (!container)
return; return;
gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size); if (!output->initialize(size.width(), size.height(), true))
if (!output->initialize(
size_in_pixel.width(), size_in_pixel.height(), true))
return; return;
ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
...@@ -468,7 +465,7 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface( ...@@ -468,7 +465,7 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface(
scoped_callback_runner.Release(); scoped_callback_runner.Release();
gl_helper->CopyTextureTo(container->texture_id(), gl_helper->CopyTextureTo(container->texture_id(),
container->size(), container->size(),
size_in_pixel, size,
addr, addr,
callback); callback);
} }
...@@ -481,13 +478,6 @@ void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { ...@@ -481,13 +478,6 @@ void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
// the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
// fewer inconsistent temporary states. // fewer inconsistent temporary states.
needs_update_texture_ = true; 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() { void RenderWidgetHostViewAura::UpdateExternalTexture() {
...@@ -507,9 +497,7 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() { ...@@ -507,9 +497,7 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() {
typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList;
ResizeLockList::iterator it = resize_locks_.begin(); ResizeLockList::iterator it = resize_locks_.begin();
while (it != resize_locks_.end()) { while (it != resize_locks_.end()) {
gfx::Size container_size = content::ConvertSizeToDIP(this, if ((*it)->expected_size() == container->size())
container->size());
if ((*it)->expected_size() == container_size)
break; break;
++it; ++it;
} }
...@@ -541,22 +529,19 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() { ...@@ -541,22 +529,19 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() {
} }
void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) { int gpu_host_id) {
current_surface_ = params_in_pixel.surface_handle; current_surface_ = params.surface_handle;
UpdateExternalTexture(); UpdateExternalTexture();
ui::Compositor* compositor = GetCompositor(); ui::Compositor* compositor = GetCompositor();
if (!compositor) { if (!compositor) {
// We have no compositor, so we have no way to display the surface. // We have no compositor, so we have no way to display the surface.
// Must still send the ACK. // Must still send the ACK.
RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id, RenderWidgetHostImpl::AcknowledgeSwapBuffers(params.route_id, gpu_host_id);
gpu_host_id);
} else { } else {
gfx::Size surface_size_in_pixel = gfx::Size surface_size =
image_transport_clients_[params_in_pixel.surface_handle]->size(); image_transport_clients_[params.surface_handle]->size();
gfx::Size surface_size = content::ConvertSizeToDIP(this,
surface_size_in_pixel);
window_->SchedulePaintInRect(gfx::Rect(surface_size)); window_->SchedulePaintInRect(gfx::Rect(surface_size));
if (!resize_locks_.empty() && !compositor->DrawPending()) { if (!resize_locks_.empty() && !compositor->DrawPending()) {
...@@ -565,12 +550,12 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( ...@@ -565,12 +550,12 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
// OnCompositingEnded(), because out-of-order execution in the GPU process // OnCompositingEnded(), because out-of-order execution in the GPU process
// might corrupt the "front buffer" for the currently issued frame. // might corrupt the "front buffer" for the currently issued frame.
RenderWidgetHostImpl::AcknowledgeSwapBuffers( RenderWidgetHostImpl::AcknowledgeSwapBuffers(
params_in_pixel.route_id, gpu_host_id); params.route_id, gpu_host_id);
} else { } else {
// Add sending an ACK to the list of things to do OnCompositingEnded // Add sending an ACK to the list of things to do OnCompositingEnded
on_compositing_ended_callbacks_.push_back( on_compositing_ended_callbacks_.push_back(
base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers, base::Bind(&RenderWidgetHostImpl::AcknowledgeSwapBuffers,
params_in_pixel.route_id, gpu_host_id)); params.route_id, gpu_host_id));
if (!compositor->HasObserver(this)) if (!compositor->HasObserver(this))
compositor->AddObserver(this); compositor->AddObserver(this);
} }
...@@ -578,9 +563,9 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( ...@@ -578,9 +563,9 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
} }
void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
int gpu_host_id) { int gpu_host_id) {
current_surface_ = params_in_pixel.surface_handle; current_surface_ = params.surface_handle;
UpdateExternalTexture(); UpdateExternalTexture();
ui::Compositor* compositor = GetCompositor(); ui::Compositor* compositor = GetCompositor();
...@@ -588,20 +573,18 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( ...@@ -588,20 +573,18 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
// We have no compositor, so we have no way to display the surface // We have no compositor, so we have no way to display the surface
// Must still send the ACK // Must still send the ACK
RenderWidgetHostImpl::AcknowledgePostSubBuffer( RenderWidgetHostImpl::AcknowledgePostSubBuffer(
params_in_pixel.route_id, gpu_host_id); params.route_id, gpu_host_id);
} else { } else {
gfx::Size surface_size_in_pixel = gfx::Size surface_size =
image_transport_clients_[params_in_pixel.surface_handle]->size(); image_transport_clients_[params.surface_handle]->size();
// Co-ordinates come in OpenGL co-ordinate space. // Co-ordinates come in OpenGL co-ordinate space.
// We need to convert to layer space. // We need to convert to layer space.
gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( window_->SchedulePaintInRect(gfx::Rect(
params_in_pixel.x, params.x,
surface_size_in_pixel.height() - params_in_pixel.y - surface_size.height() - params.y - params.height,
params_in_pixel.height, params.width,
params_in_pixel.width, params.height));
params_in_pixel.height));
window_->SchedulePaintInRect(rect_to_paint);
if (!resize_locks_.empty() && !compositor->DrawPending()) { if (!resize_locks_.empty() && !compositor->DrawPending()) {
// If we are waiting for the resize, fast-track the ACK. // If we are waiting for the resize, fast-track the ACK.
...@@ -609,12 +592,12 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( ...@@ -609,12 +592,12 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
// OnCompositingEnded(), because out-of-order execution in the GPU process // OnCompositingEnded(), because out-of-order execution in the GPU process
// might corrupt the "front buffer" for the currently issued frame. // might corrupt the "front buffer" for the currently issued frame.
RenderWidgetHostImpl::AcknowledgePostSubBuffer( RenderWidgetHostImpl::AcknowledgePostSubBuffer(
params_in_pixel.route_id, gpu_host_id); params.route_id, gpu_host_id);
} else { } else {
// Add sending an ACK to the list of things to do OnCompositingEnded // Add sending an ACK to the list of things to do OnCompositingEnded
on_compositing_ended_callbacks_.push_back( on_compositing_ended_callbacks_.push_back(
base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer, base::Bind(&RenderWidgetHostImpl::AcknowledgePostSubBuffer,
params_in_pixel.route_id, gpu_host_id)); params.route_id, gpu_host_id));
if (!compositor->HasObserver(this)) if (!compositor->HasObserver(this))
compositor->AddObserver(this); compositor->AddObserver(this);
} }
...@@ -633,13 +616,13 @@ bool RenderWidgetHostViewAura::HasAcceleratedSurface( ...@@ -633,13 +616,13 @@ bool RenderWidgetHostViewAura::HasAcceleratedSurface(
} }
void RenderWidgetHostViewAura::AcceleratedSurfaceNew( void RenderWidgetHostViewAura::AcceleratedSurfaceNew(
int32 width_in_pixel, int32 width,
int32 height_in_pixel, int32 height,
uint64* surface_handle, uint64* surface_handle,
TransportDIB::Handle* shm_handle) { TransportDIB::Handle* shm_handle) {
ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient( scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient(
gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); gfx::Size(width, height), surface_handle));
if (!surface) { if (!surface) {
LOG(ERROR) << "Failed to create ImageTransportClient"; LOG(ERROR) << "Failed to create ImageTransportClient";
return; return;
......
...@@ -99,16 +99,16 @@ class RenderWidgetHostViewAura ...@@ -99,16 +99,16 @@ class RenderWidgetHostViewAura
base::Callback<void(bool)> callback) OVERRIDE; base::Callback<void(bool)> callback) OVERRIDE;
virtual void OnAcceleratedCompositingStateChange() OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
virtual void AcceleratedSurfaceBuffersSwapped( virtual void AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) OVERRIDE; int gpu_host_id) OVERRIDE;
virtual void AcceleratedSurfacePostSubBuffer( virtual void AcceleratedSurfacePostSubBuffer(
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
int gpu_host_id) OVERRIDE; int gpu_host_id) OVERRIDE;
virtual void AcceleratedSurfaceSuspend() OVERRIDE; virtual void AcceleratedSurfaceSuspend() OVERRIDE;
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
virtual void AcceleratedSurfaceNew( virtual void AcceleratedSurfaceNew(
int32 width_in_pixel, int32 width,
int32 height_in_pixel, int32 height,
uint64* surface_id, uint64* surface_id,
TransportDIB::Handle* surface_handle) OVERRIDE; TransportDIB::Handle* surface_handle) OVERRIDE;
virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE;
......
...@@ -546,12 +546,6 @@ WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, ...@@ -546,12 +546,6 @@ WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh,
prefs.max_untiled_layer_height = prefs.max_untiled_layer_height =
GetSwitchValueAsInt(command_line, switches::kMaxUntiledLayerHeight, 1); GetSwitchValueAsInt(command_line, switches::kMaxUntiledLayerHeight, 1);
if (gfx::Screen::IsDIPEnabled()) {
// Only apply when using DIP coordinate system as this setting interferes
// with fixed layout mode.
prefs.apply_default_device_scale_factor_in_compositor = true;
}
content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs);
return prefs; return prefs;
......
...@@ -137,7 +137,6 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebPreferences) ...@@ -137,7 +137,6 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(default_font_size) IPC_STRUCT_TRAITS_MEMBER(default_font_size)
IPC_STRUCT_TRAITS_MEMBER(default_fixed_font_size) IPC_STRUCT_TRAITS_MEMBER(default_fixed_font_size)
IPC_STRUCT_TRAITS_MEMBER(default_device_scale_factor) IPC_STRUCT_TRAITS_MEMBER(default_device_scale_factor)
IPC_STRUCT_TRAITS_MEMBER(apply_default_device_scale_factor_in_compositor)
IPC_STRUCT_TRAITS_MEMBER(minimum_font_size) IPC_STRUCT_TRAITS_MEMBER(minimum_font_size)
IPC_STRUCT_TRAITS_MEMBER(minimum_logical_font_size) IPC_STRUCT_TRAITS_MEMBER(minimum_logical_font_size)
IPC_STRUCT_TRAITS_MEMBER(default_encoding) IPC_STRUCT_TRAITS_MEMBER(default_encoding)
......
...@@ -476,8 +476,6 @@ ...@@ -476,8 +476,6 @@
'browser/renderer_host/cross_site_resource_handler.h', 'browser/renderer_host/cross_site_resource_handler.h',
'browser/renderer_host/database_message_filter.cc', 'browser/renderer_host/database_message_filter.cc',
'browser/renderer_host/database_message_filter.h', 'browser/renderer_host/database_message_filter.h',
'browser/renderer_host/dip_util.cc',
'browser/renderer_host/dip_util.h',
'browser/renderer_host/doomed_resource_handler.cc', 'browser/renderer_host/doomed_resource_handler.cc',
'browser/renderer_host/doomed_resource_handler.h', 'browser/renderer_host/doomed_resource_handler.h',
'browser/renderer_host/file_utilities_message_filter.cc', 'browser/renderer_host/file_utilities_message_filter.cc',
......
...@@ -162,12 +162,12 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView { ...@@ -162,12 +162,12 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView {
// too far ahead. They may all be zero, in which case no flow control is // too far ahead. They may all be zero, in which case no flow control is
// enforced; this case is currently used for accelerated plugins. // enforced; this case is currently used for accelerated plugins.
virtual void AcceleratedSurfaceBuffersSwapped( virtual void AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) = 0; int gpu_host_id) = 0;
// Similar to above, except |params.(x|y|width|height)| define the region // Similar to above, except |params.(x|y|width|height)| define the region
// of the surface that changed. // of the surface that changed.
virtual void AcceleratedSurfacePostSubBuffer( virtual void AcceleratedSurfacePostSubBuffer(
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
int gpu_host_id) = 0; int gpu_host_id) = 0;
// Release the accelerated surface temporarily. It will be recreated on the // Release the accelerated surface temporarily. It will be recreated on the
...@@ -221,8 +221,8 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView { ...@@ -221,8 +221,8 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView {
#if defined(USE_AURA) #if defined(USE_AURA)
virtual void AcceleratedSurfaceNew( virtual void AcceleratedSurfaceNew(
int32 width_in_pixel, int32 width,
int32 height_in_pixel, int32 height,
uint64* surface_id, uint64* surface_id,
TransportDIB::Handle* surface_handle) = 0; TransportDIB::Handle* surface_handle) = 0;
virtual void AcceleratedSurfaceRelease(uint64 surface_id) = 0; virtual void AcceleratedSurfaceRelease(uint64 surface_id) = 0;
......
...@@ -53,7 +53,7 @@ Layer::Layer() ...@@ -53,7 +53,7 @@ Layer::Layer()
layer_updated_externally_(false), layer_updated_externally_(false),
opacity_(1.0f), opacity_(1.0f),
delegate_(NULL), delegate_(NULL),
scale_content_(true), scale_canvas_(true),
device_scale_factor_(1.0f) { device_scale_factor_(1.0f) {
CreateWebLayer(); CreateWebLayer();
} }
...@@ -67,7 +67,7 @@ Layer::Layer(LayerType type) ...@@ -67,7 +67,7 @@ Layer::Layer(LayerType type)
layer_updated_externally_(false), layer_updated_externally_(false),
opacity_(1.0f), opacity_(1.0f),
delegate_(NULL), delegate_(NULL),
scale_content_(true), scale_canvas_(true),
device_scale_factor_(1.0f) { device_scale_factor_(1.0f) {
CreateWebLayer(); CreateWebLayer();
} }
...@@ -340,7 +340,9 @@ void Layer::SendDamagedRects() { ...@@ -340,7 +340,9 @@ void Layer::SendDamagedRects() {
sk_damaged.width(), sk_damaged.width(),
sk_damaged.height()); sk_damaged.height());
if (scale_content_ && web_layer_is_accelerated_) { // TODO(pkotwicz): Remove this once we are no longer linearly upscaling
// web contents when DIP is enabled (crbug.com/127455).
if (web_layer_is_accelerated_) {
damaged.Inset(-1, -1); damaged.Inset(-1, -1);
damaged = damaged.Intersect(bounds_); damaged = damaged.Intersect(bounds_);
} }
...@@ -388,14 +390,14 @@ void Layer::paintContents(WebKit::WebCanvas* web_canvas, ...@@ -388,14 +390,14 @@ void Layer::paintContents(WebKit::WebCanvas* web_canvas,
const WebKit::WebRect& clip) { const WebKit::WebRect& clip) {
TRACE_EVENT0("ui", "Layer::paintContents"); TRACE_EVENT0("ui", "Layer::paintContents");
gfx::Canvas canvas(web_canvas); gfx::Canvas canvas(web_canvas);
bool scale_content = scale_content_; bool scale_canvas = scale_canvas_;
if (scale_content) { if (scale_canvas) {
canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_), canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_),
SkFloatToScalar(device_scale_factor_)); SkFloatToScalar(device_scale_factor_));
} }
if (delegate_) if (delegate_)
delegate_->OnPaintLayer(&canvas); delegate_->OnPaintLayer(&canvas);
if (scale_content) if (scale_canvas)
canvas.Restore(); canvas.Restore();
} }
...@@ -589,13 +591,13 @@ void Layer::RecomputeDrawsContentAndUVRect() { ...@@ -589,13 +591,13 @@ void Layer::RecomputeDrawsContentAndUVRect() {
WebKit::WebExternalTextureLayer texture_layer = WebKit::WebExternalTextureLayer texture_layer =
web_layer_.to<WebKit::WebExternalTextureLayer>(); web_layer_.to<WebKit::WebExternalTextureLayer>();
texture_layer.setTextureId(should_draw ? texture_id : 0); texture_layer.setTextureId(should_draw ? texture_id : 0);
gfx::Size texture_size = texture_->size();
gfx::Size texture_size; // As WebKit does not support DIP, WebKit is told of coordinates in DIP
if (scale_content_) // as if they were pixel coordinates. The texture is scaled here via
texture_size = texture_->size(); // the setBounds call.
else // TODO(pkotwicz): Fix this code to take in account textures with pixel
texture_size = ConvertSizeToDIP(this, texture_->size()); // sizes once WebKit understands DIP. http://crbug.com/127455
gfx::Size size(std::min(bounds().width(), texture_size.width()), gfx::Size size(std::min(bounds().width(), texture_size.width()),
std::min(bounds().height(), texture_size.height())); std::min(bounds().height(), texture_size.height()));
WebKit::WebFloatRect rect( WebKit::WebFloatRect rect(
......
...@@ -198,12 +198,10 @@ class COMPOSITOR_EXPORT Layer : ...@@ -198,12 +198,10 @@ class COMPOSITOR_EXPORT Layer :
// Notifies the layer that the device scale factor has changed. // Notifies the layer that the device scale factor has changed.
void OnDeviceScaleFactorChanged(float device_scale_factor); void OnDeviceScaleFactorChanged(float device_scale_factor);
// Sets whether the layer should scale its content. If true, the canvas will // Sets if the layer should scale the canvas before passing to
// be scaled in software rendering mode before it is passed to // |LayerDelegate::OnLayerPaint|. Set to false if the delegate
// |LayerDelegate::OnPaint| and the texture will be scaled in accelerated // handles scaling.
// mode. Set to false if the delegate handles scaling and the texture is void set_scale_canvas(bool scale_canvas) { scale_canvas_ = scale_canvas; }
// the correct pixel size.
void set_scale_content(bool scale_content) { scale_content_ = scale_content; }
// Sometimes the Layer is being updated by something other than SetCanvas // Sometimes the Layer is being updated by something other than SetCanvas
// (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT).
...@@ -301,9 +299,9 @@ class COMPOSITOR_EXPORT Layer : ...@@ -301,9 +299,9 @@ class COMPOSITOR_EXPORT Layer :
bool web_layer_is_accelerated_; bool web_layer_is_accelerated_;
bool show_debug_borders_; bool show_debug_borders_;
// If true, the layer scales the canvas and the texture with the device scale // If true, the layer scales the canvas using device scale factor
// factor as appropriate. When true, the texture size is in DIP. // before passing to LayerDelegate::OnLayerPaint.
bool scale_content_; bool scale_canvas_;
// A cached copy of |Compositor::device_scale_factor()|. // A cached copy of |Compositor::device_scale_factor()|.
float device_scale_factor_; float device_scale_factor_;
......
...@@ -38,7 +38,6 @@ WebPreferences::WebPreferences() ...@@ -38,7 +38,6 @@ WebPreferences::WebPreferences()
minimum_logical_font_size(6), minimum_logical_font_size(6),
default_device_scale_factor(1), default_device_scale_factor(1),
default_encoding("ISO-8859-1"), default_encoding("ISO-8859-1"),
apply_default_device_scale_factor_in_compositor(false),
javascript_enabled(true), javascript_enabled(true),
web_security_enabled(true), web_security_enabled(true),
javascript_can_open_windows_automatically(true), javascript_can_open_windows_automatically(true),
...@@ -199,8 +198,6 @@ void WebPreferences::Apply(WebView* web_view) const { ...@@ -199,8 +198,6 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setMinimumLogicalFontSize(minimum_logical_font_size); settings->setMinimumLogicalFontSize(minimum_logical_font_size);
settings->setDefaultDeviceScaleFactor(default_device_scale_factor); settings->setDefaultDeviceScaleFactor(default_device_scale_factor);
settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding)); settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding));
settings->setApplyDefaultDeviceScaleFactorInCompositor(
apply_default_device_scale_factor_in_compositor);
settings->setJavaScriptEnabled(javascript_enabled); settings->setJavaScriptEnabled(javascript_enabled);
settings->setWebSecurityEnabled(web_security_enabled); settings->setWebSecurityEnabled(web_security_enabled);
settings->setJavaScriptCanOpenWindowsAutomatically( settings->setJavaScriptCanOpenWindowsAutomatically(
......
...@@ -47,7 +47,6 @@ struct WEBKIT_GLUE_EXPORT WebPreferences { ...@@ -47,7 +47,6 @@ struct WEBKIT_GLUE_EXPORT WebPreferences {
int minimum_logical_font_size; int minimum_logical_font_size;
int default_device_scale_factor; int default_device_scale_factor;
std::string default_encoding; std::string default_encoding;
bool apply_default_device_scale_factor_in_compositor;
bool javascript_enabled; bool javascript_enabled;
bool web_security_enabled; bool web_security_enabled;
bool javascript_can_open_windows_automatically; bool javascript_can_open_windows_automatically;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment