Index: components/exo/surface.cc |
diff --git a/components/exo/surface.cc b/components/exo/surface.cc |
index d822e5b03a59697ebc90f6d5852593e55966a454..e4151cb1a14e3d5693f5e79d0a6ea199244ed7f7 100644 |
--- a/components/exo/surface.cc |
+++ b/components/exo/surface.cc |
@@ -19,6 +19,7 @@ |
#include "ui/compositor/layer.h" |
#include "ui/gfx/buffer_format_util.h" |
#include "ui/gfx/gpu_memory_buffer.h" |
+#include "ui/gfx/transform_util.h" |
DECLARE_WINDOW_PROPERTY_TYPE(exo::Surface*); |
@@ -90,6 +91,7 @@ class EmptyWindowDelegate : public aura::WindowDelegate { |
Surface::Surface() |
: aura::Window(new EmptyWindowDelegate), |
has_pending_contents_(false), |
+ pending_buffer_scale_(1.0f), |
needs_commit_surface_hierarchy_(false), |
update_contents_after_successful_compositing_(false), |
compositor_(nullptr), |
@@ -149,6 +151,12 @@ void Surface::SetOpaqueRegion(const SkRegion& region) { |
pending_opaque_region_ = region; |
} |
+void Surface::SetBufferScale(float scale) { |
+ TRACE_EVENT1("exo", "Surface::SetBufferScale", "scale", scale); |
+ |
+ pending_buffer_scale_ = scale; |
+} |
+ |
void Surface::AddSubSurface(Surface* sub_surface) { |
TRACE_EVENT1("exo", "Surface::AddSubSurface", "sub_surface", |
sub_surface->AsTracedValue()); |
@@ -271,10 +279,14 @@ void Surface::CommitSurfaceHierarchy() { |
texture_mailbox_release_callback.Pass(), |
texture_mailbox.size_in_pixels()); |
layer()->SetTextureFlipped(false); |
- layer()->SetBounds(gfx::Rect(layer()->bounds().origin(), |
- texture_mailbox.size_in_pixels())); |
+ gfx::Size contents_size(gfx::ScaleToFlooredSize( |
+ texture_mailbox.size_in_pixels(), 1.0f / pending_buffer_scale_)); |
+ layer()->SetBounds(gfx::Rect(layer()->bounds().origin(), contents_size)); |
layer()->SetFillsBoundsOpaquely(pending_opaque_region_.contains( |
- gfx::RectToSkIRect(gfx::Rect(texture_mailbox.size_in_pixels())))); |
+ gfx::RectToSkIRect(gfx::Rect(contents_size)))); |
+ layer()->SetTransform(gfx::GetScaleTransform( |
+ gfx::Rect(texture_mailbox.size_in_pixels()).CenterPoint(), |
+ 1.0f / pending_buffer_scale_)); |
lpique
2016/01/04 19:36:20
The call to ScaleToFlooredSize() includes (as the
reveman
2016/01/05 09:02:48
Good point. Done.
|
} else { |
// Show solid color content if no buffer is attached or we failed |
// to produce a texture mailbox for the currently attached buffer. |
@@ -331,7 +343,9 @@ void Surface::CommitSurfaceHierarchy() { |
} |
gfx::Size Surface::GetPreferredSize() const { |
- return pending_buffer_ ? pending_buffer_->GetSize() : layer()->size(); |
+ return pending_buffer_ ? gfx::ScaleToFlooredSize(pending_buffer_->GetSize(), |
+ 1.0f / pending_buffer_scale_) |
+ : layer()->size(); |
} |
bool Surface::IsSynchronized() const { |