summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 02:33:43 +0000
committeralexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 02:33:43 +0000
commit396fbb77b1cd9355cc6c1e1aa4dea2e34ee42dcd (patch)
tree8c5f864dcdeea49b8ad7426897551093fbbfc14c
parent05741e11c3470e1be909ceda93b0d97a199278a8 (diff)
downloadchromium_src-396fbb77b1cd9355cc6c1e1aa4dea2e34ee42dcd.zip
chromium_src-396fbb77b1cd9355cc6c1e1aa4dea2e34ee42dcd.tar.gz
chromium_src-396fbb77b1cd9355cc6c1e1aa4dea2e34ee42dcd.tar.bz2
Webview: Introduce gutters around the image when resizeing contents and when autosize is turned on.
Adds a background layer and parents the texture_layer to it. Background layer shows a gutter when the texture layer is smaller and clips it to the size of the container when the texture layer is larger. BUG=169803 Review URL: https://chromiumcodereview.appspot.com/12047019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178215 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/browser_plugin/browser_plugin.cc4
-rw-r--r--content/renderer/browser_plugin/browser_plugin_compositing_helper.cc44
-rw-r--r--content/renderer/browser_plugin/browser_plugin_compositing_helper.h5
3 files changed, 18 insertions, 35 deletions
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index f42e02a..76d1ad5 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -936,10 +936,6 @@ void BrowserPlugin::updateGeometry(
int old_width = width();
int old_height = height();
plugin_rect_ = window_rect;
- if (compositing_helper_) {
- compositing_helper_->SetContainerSize(gfx::Size(window_rect.width,
- window_rect.height));
- }
// In AutoSize mode, guests don't care when the BrowserPlugin container is
// resized. If |!resize_ack_received_|, then we are still waiting on a
// previous resize to be ACK'ed and so we don't issue additional resizes
diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc
index e9d5393..5d10f13 100644
--- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc
+++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc
@@ -4,6 +4,7 @@
#include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h"
+#include "cc/solid_color_layer.h"
#include "cc/texture_layer.h"
#include "content/common/browser_plugin_messages.h"
#include "content/renderer/browser_plugin/browser_plugin_manager.h"
@@ -33,7 +34,15 @@ BrowserPluginCompositingHelper::~BrowserPluginCompositingHelper() {
void BrowserPluginCompositingHelper::EnableCompositing(bool enable) {
if (enable && !texture_layer_) {
texture_layer_ = cc::TextureLayer::createForMailbox();
- web_layer_.reset(new WebKit::WebLayerImpl(texture_layer_));
+ texture_layer_->setIsDrawable(true);
+ texture_layer_->setContentsOpaque(true);
+
+ background_layer_ = cc::SolidColorLayer::create();
+ background_layer_->setMasksToBounds(true);
+ background_layer_->setBackgroundColor(
+ SkColorSetARGBInline(255, 255, 255, 255));
+ background_layer_->addChild(texture_layer_);
+ web_layer_.reset(new WebKit::WebLayerImpl(background_layer_));
}
container_->setWebLayer(enable ? web_layer_.get() : NULL);
@@ -102,6 +111,7 @@ void BrowserPluginCompositingHelper::OnContainerDestroy() {
container_ = NULL;
texture_layer_ = NULL;
+ background_layer_ = NULL;
web_layer_.reset();
}
@@ -123,13 +133,13 @@ void BrowserPluginCompositingHelper::OnBuffersSwapped(
// During resize, the container size changes first and then some time
// later, a new buffer with updated size will arrive. During this process,
// we need to make sure that things are still displayed pixel perfect.
- // We accomplish this by modifying texture coordinates in the layer,
- // and either buffer size or container size change triggers the need
- // to also update texture coordinates. Visually, this will either
- // display a smaller part of the buffer or introduce a gutter around it.
+ // We accomplish this by modifying bounds of the texture layer only
+ // when a new buffer arrives.
+ // Visually, this will either display a smaller part of the buffer
+ // or introduce a gutter around it.
if (buffer_size_ != size) {
buffer_size_ = size;
- UpdateUVRect();
+ texture_layer_->setBounds(buffer_size_);
}
bool current_mailbox_valid = !mailbox_name.empty();
@@ -152,26 +162,4 @@ void BrowserPluginCompositingHelper::OnBuffersSwapped(
last_mailbox_valid_ = current_mailbox_valid;
}
-void BrowserPluginCompositingHelper::SetContainerSize(const gfx::Size& size) {
- if (container_size_ == size)
- return;
-
- container_size_ = size;
- UpdateUVRect();
-}
-
-void BrowserPluginCompositingHelper::UpdateUVRect() {
- if (!texture_layer_)
- return;
-
- gfx::RectF uv_rect(0, 0, 1, 1);
- if (!buffer_size_.IsEmpty() && !container_size_.IsEmpty()) {
- uv_rect.set_width(static_cast<float>(container_size_.width()) /
- static_cast<float>(buffer_size_.width()));
- uv_rect.set_height(static_cast<float>(container_size_.height()) /
- static_cast<float>(buffer_size_.height()));
- }
- texture_layer_->setUV(uv_rect.origin(), uv_rect.bottom_right());
-}
-
} // namespace content
diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.h b/content/renderer/browser_plugin/browser_plugin_compositing_helper.h
index 6377531..e041259 100644
--- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.h
+++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.h
@@ -13,6 +13,7 @@
#include "ui/gfx/size.h"
namespace cc {
+class SolidColorLayer;
class TextureLayer;
}
@@ -37,7 +38,6 @@ class CONTENT_EXPORT BrowserPluginCompositingHelper :
const std::string& mailbox_name,
int gpu_route_id,
int gpu_host_id);
- void SetContainerSize(const gfx::Size&);
protected:
// Friend RefCounted so that the dtor can be non-public.
friend class base::RefCounted<BrowserPluginCompositingHelper>;
@@ -49,15 +49,14 @@ class CONTENT_EXPORT BrowserPluginCompositingHelper :
int gpu_route_id,
int gpu_host_id,
unsigned sync_point);
- void UpdateUVRect();
int host_routing_id_;
bool last_mailbox_valid_;
bool ack_pending_;
gfx::Size buffer_size_;
- gfx::Size container_size_;
+ scoped_refptr<cc::SolidColorLayer> background_layer_;
scoped_refptr<cc::TextureLayer> texture_layer_;
scoped_ptr<WebKit::WebLayer> web_layer_;
WebKit::WebPluginContainer* container_;