Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: ui/compositor/layer.cc

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passed(&foo) instead for Passed(foo.Pass()). Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index a2f0a95d1ae363f42eafa36b6f36e81d9a8c0bdc..3949402e4961abca80cd21a83157b9712abcf118 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);
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698