summaryrefslogtreecommitdiffstats
path: root/ui/compositor
diff options
context:
space:
mode:
authorskaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-08 04:38:51 +0000
committerskaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-08 04:38:51 +0000
commit42f40a546f90a81727c05aea44ce299d97d7507b (patch)
tree3004f86f245e15cea8606868cdbdac2d0d1b0ac0 /ui/compositor
parent165e50b4b57c105da46d662273f1ce4a164b195d (diff)
downloadchromium_src-42f40a546f90a81727c05aea44ce299d97d7507b.zip
chromium_src-42f40a546f90a81727c05aea44ce299d97d7507b.tar.gz
chromium_src-42f40a546f90a81727c05aea44ce299d97d7507b.tar.bz2
[Aura] Added Support for rendering software compositor frames as cc::TextureLayers through cc::TextureMailbox.
BUG=161008 R=piman TBR=jschuh,ben Review URL: https://chromiumcodereview.appspot.com/15001027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/compositor')
-rw-r--r--ui/compositor/layer.cc48
-rw-r--r--ui/compositor/layer.h12
2 files changed, 54 insertions, 6 deletions
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index a2f0a95..3949402 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -86,6 +86,7 @@ Layer::Layer(LayerType type)
zoom_(1),
zoom_inset_(0),
delegate_(NULL),
+ cc_layer_(NULL),
scale_content_(true),
device_scale_factor_(1.0f) {
CreateWebLayer();
@@ -514,6 +515,32 @@ void Layer::SetExternalTexture(Texture* texture) {
RecomputeDrawsContentAndUVRect();
}
+void Layer::SetTextureMailbox(const cc::TextureMailbox& mailbox,
+ float scale_factor) {
+ DCHECK_EQ(type_, LAYER_TEXTURED);
+ DCHECK(!solid_color_layer_);
+ layer_updated_externally_ = true;
+ texture_ = NULL;
+ if (!texture_layer_ || !texture_layer_->uses_mailbox()) {
+ scoped_refptr<cc::TextureLayer> new_layer =
+ cc::TextureLayer::CreateForMailbox(this);
+ new_layer->SetFlipped(false);
+ SwitchToLayer(new_layer);
+ texture_layer_ = new_layer;
+ }
+ texture_layer_->SetTextureMailbox(mailbox);
+ mailbox_ = mailbox;
+ mailbox_scale_factor_ = scale_factor;
+ RecomputeDrawsContentAndUVRect();
+}
+
+cc::TextureMailbox Layer::GetTextureMailbox(float* scale_factor) {
+ if (scale_factor)
+ *scale_factor = mailbox_scale_factor_;
+ cc::TextureMailbox::ReleaseCallback callback;
+ return mailbox_.CopyWithNewCallback(callback);
+}
+
void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame,
gfx::Size frame_size_in_dip) {
DCHECK_EQ(type_, LAYER_TEXTURED);
@@ -640,7 +667,9 @@ unsigned Layer::PrepareTexture(cc::ResourceUpdateQueue* queue) {
WebKit::WebGraphicsContext3D* Layer::Context3d() {
DCHECK(texture_layer_.get());
- return texture_->HostContext3D();
+ if (texture_)
+ return texture_->HostContext3D();
+ return NULL;
}
bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox) {
@@ -918,11 +947,18 @@ void Layer::RecomputeDrawsContentAndUVRect() {
DCHECK(cc_layer_);
gfx::Size size(bounds_.size());
if (texture_layer_.get()) {
- DCHECK(texture_.get());
-
- float texture_scale_factor = 1.0f / texture_->device_scale_factor();
- gfx::Size texture_size = gfx::ToFlooredSize(
- gfx::ScaleSize(texture_->size(), texture_scale_factor));
+ gfx::Size texture_size;
+ if (!texture_layer_->uses_mailbox()) {
+ DCHECK(texture_);
+ float texture_scale_factor = 1.0f / texture_->device_scale_factor();
+ texture_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(texture_->size(), texture_scale_factor));
+ } else {
+ DCHECK(mailbox_.IsSharedMemory());
+ float texture_scale_factor = 1.0f / mailbox_scale_factor_;
+ texture_size = gfx::ToFlooredSize(
+ gfx::ScaleSize(mailbox_.shared_memory_size(), texture_scale_factor));
+ }
size.SetToMin(texture_size);
gfx::PointF uv_top_left(0.f, 0.f);
diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h
index a5afd6b..1159d0b 100644
--- a/ui/compositor/layer.h
+++ b/ui/compositor/layer.h
@@ -17,6 +17,7 @@
#include "cc/base/scoped_ptr_vector.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/texture_layer_client.h"
+#include "cc/resources/texture_mailbox.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/compositor/compositor.h"
@@ -250,6 +251,11 @@ class COMPOSITOR_EXPORT Layer
void SetExternalTexture(ui::Texture* texture);
ui::Texture* external_texture() { return texture_.get(); }
+ // Set new TextureMailbox for this layer. Note that |mailbox| may hold a
+ // shared memory resource or an actual mailbox for a texture.
+ void SetTextureMailbox(const cc::TextureMailbox& mailbox, float scale_factor);
+ cc::TextureMailbox GetTextureMailbox(float* scale_factor);
+
// Sets a delegated frame, coming from a child compositor.
void SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame,
gfx::Size frame_size_in_dip);
@@ -465,6 +471,12 @@ class COMPOSITOR_EXPORT Layer
// A cached copy of |Compositor::device_scale_factor()|.
float device_scale_factor_;
+ // A cached copy of the TextureMailbox given texture_layer_.
+ cc::TextureMailbox mailbox_;
+
+ // Device scale factor in which mailbox_ was rendered in.
+ float mailbox_scale_factor_;
+
// The size of the delegated frame in DIP, set when SetDelegatedFrame was
// called.
gfx::Size delegated_frame_size_in_dip_;