diff options
-rw-r--r-- | content/browser/renderer_host/image_transport_factory.cc | 16 | ||||
-rw-r--r-- | content/browser/renderer_host/image_transport_factory.h | 6 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 8 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.h | 3 | ||||
-rw-r--r-- | ui/aura/bench/bench_main.cc | 2 | ||||
-rw-r--r-- | ui/compositor/compositor.cc | 5 | ||||
-rw-r--r-- | ui/compositor/compositor.h | 4 | ||||
-rw-r--r-- | ui/compositor/layer.cc | 8 |
8 files changed, 37 insertions, 15 deletions
diff --git a/content/browser/renderer_host/image_transport_factory.cc b/content/browser/renderer_host/image_transport_factory.cc index 1906730..77bc379 100644 --- a/content/browser/renderer_host/image_transport_factory.cc +++ b/content/browser/renderer_host/image_transport_factory.cc @@ -61,12 +61,14 @@ class DefaultTransportFactory virtual scoped_refptr<ui::Texture> CreateTransportClient( const gfx::Size& size, + float device_scale_factor, uint64 transport_handle) OVERRIDE { return NULL; } virtual scoped_refptr<ui::Texture> CreateOwnedTexture( const gfx::Size& size, + float device_scale_factor, unsigned int texture_id) OVERRIDE { return NULL; } @@ -97,8 +99,9 @@ class ImageTransportClientTexture : public ui::Texture { ImageTransportClientTexture( WebKit::WebGraphicsContext3D* host_context, const gfx::Size& size, + float device_scale_factor, uint64 surface_id) - : ui::Texture(true, size), + : ui::Texture(true, size, device_scale_factor), host_context_(host_context) { set_texture_id(surface_id); } @@ -123,8 +126,9 @@ class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { public: OwnedTexture(WebKit::WebGraphicsContext3D* host_context, const gfx::Size& size, + float device_scale_factor, unsigned int texture_id) - : ui::Texture(true, size), + : ui::Texture(true, size, device_scale_factor), host_context_(host_context) { ImageTransportFactory::GetInstance()->AddObserver(this); set_texture_id(texture_id); @@ -281,22 +285,26 @@ class GpuProcessTransportFactory : virtual scoped_refptr<ui::Texture> CreateTransportClient( const gfx::Size& size, + float device_scale_factor, uint64 transport_handle) { if (!shared_context_.get()) return NULL; scoped_refptr<ImageTransportClientTexture> image( new ImageTransportClientTexture(shared_context_.get(), - size, transport_handle)); + size, device_scale_factor, + transport_handle)); return image; } virtual scoped_refptr<ui::Texture> CreateOwnedTexture( const gfx::Size& size, + float device_scale_factor, unsigned int texture_id) OVERRIDE { if (!shared_context_.get()) return NULL; scoped_refptr<OwnedTexture> image( - new OwnedTexture(shared_context_.get(), size, texture_id)); + new OwnedTexture(shared_context_.get(), size, device_scale_factor, + texture_id)); return image; } diff --git a/content/browser/renderer_host/image_transport_factory.h b/content/browser/renderer_host/image_transport_factory.h index 597ee71..44b10b0 100644 --- a/content/browser/renderer_host/image_transport_factory.h +++ b/content/browser/renderer_host/image_transport_factory.h @@ -69,16 +69,18 @@ class ImageTransportFactory { // Destroys a shared surface handle. virtual void DestroySharedSurfaceHandle(gfx::GLSurfaceHandle surface) = 0; - // Creates a transport texture of a given size, and using the opaque handle - // sent by the GPU process. + // Creates a transport texture of a given size and scale factor, and using the + // opaque handle sent by the GPU process. virtual scoped_refptr<ui::Texture> CreateTransportClient( const gfx::Size& size, + float device_scale_factor, uint64 transport_handle) = 0; // Variant of CreateTransportClient() that deletes the texture on the GPU when // the returned value is deleted. virtual scoped_refptr<ui::Texture> CreateOwnedTexture( const gfx::Size& size, + float device_scale_factor, unsigned int texture_id) = 0; // Gets a GLHelper instance, associated with the shared context. This 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 28162bc..fbd5aa0 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -262,6 +262,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) text_input_type_(ui::TEXT_INPUT_TYPE_NONE), can_compose_inline_(true), has_composition_text_(false), + device_scale_factor_(1.0f), current_surface_(0), current_surface_is_protected_(true), current_surface_in_use_by_compositor_(true), @@ -926,7 +927,8 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceNew( uint64 surface_handle) { ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); scoped_refptr<ui::Texture> surface(factory->CreateTransportClient( - gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); + gfx::Size(width_in_pixel, height_in_pixel), device_scale_factor_, + surface_handle)); if (!surface) { LOG(ERROR) << "Failed to create ImageTransport texture"; return; @@ -1349,6 +1351,7 @@ void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( if (!host_) return; + device_scale_factor_ = device_scale_factor; BackingStoreAura* backing_store = static_cast<BackingStoreAura*>( host_->GetBackingStore(false)); if (backing_store) // NULL in hardware path. @@ -1410,7 +1413,8 @@ scoped_refptr<ui::Texture> RenderWidgetHostViewAura::CopyTexture() { return scoped_refptr<ui::Texture>(); return scoped_refptr<ui::Texture>( - factory->CreateOwnedTexture(container->size(), texture_id)); + factory->CreateOwnedTexture( + container->size(), device_scale_factor_, texture_id)); } //////////////////////////////////////////////////////////////////////////////// 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 04d814c..a36c811 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -324,6 +324,9 @@ class RenderWidgetHostViewAura // Current tooltip text. string16 tooltip_; + // The scale factor of the display the renderer is currently on. + float device_scale_factor_; + std::vector< base::Callback<void(ui::Compositor*)> > on_compositing_did_commit_callbacks_; diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc index 5be1b29..09eb544 100644 --- a/ui/aura/bench/bench_main.cc +++ b/ui/aura/bench/bench_main.cc @@ -135,7 +135,7 @@ class BenchCompositorObserver : public ui::CompositorObserver { class WebGLTexture : public ui::Texture { public: WebGLTexture(WebGraphicsContext3D* context, const gfx::Size& size) - : ui::Texture(false, size), + : ui::Texture(false, size, 1.0f), context_(context) { set_texture_id(context_->createTexture()); context_->bindTexture(GL_TEXTURE_2D, texture_id()); diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 03a9f2e..b284f7f 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -125,10 +125,11 @@ WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon( return context; } -Texture::Texture(bool flipped, const gfx::Size& size) +Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor) : texture_id_(0), flipped_(flipped), - size_(size) { + size_(size), + device_scale_factor_(device_scale_factor) { } Texture::~Texture() { diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index 8baada9..0f62979 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -94,12 +94,13 @@ class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { // to a layer. class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { public: - Texture(bool flipped, const gfx::Size& size); + Texture(bool flipped, const gfx::Size& size, float device_scale_factor); unsigned int texture_id() const { return texture_id_; } void set_texture_id(unsigned int id) { texture_id_ = id; } bool flipped() const { return flipped_; } gfx::Size size() const { return size_; } + float device_scale_factor() const { return device_scale_factor_; } virtual WebKit::WebGraphicsContext3D* HostContext3D() = 0; protected: @@ -111,6 +112,7 @@ class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { unsigned int texture_id_; bool flipped_; gfx::Size size_; // in pixel + float device_scale_factor_; DISALLOW_COPY_AND_ASSIGN(Texture); }; diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 7e79649..c3856cc 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -749,10 +749,12 @@ void Layer::RecomputeDrawsContentAndUVRect() { DCHECK(texture_); gfx::Size texture_size; - if (scale_content_) + if (scale_content_) { texture_size = texture_->size(); - else - texture_size = ConvertSizeToDIP(this, texture_->size()); + } else { + texture_size = + texture_->size().Scale(1.0f / texture_->device_scale_factor()); + } gfx::Size size(std::min(bounds().width(), texture_size.width()), std::min(bounds().height(), texture_size.height())); |