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

Side by Side Diff: cc/layers/texture_layer_impl.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: Rebased. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/texture_layer_impl.h" 5 #include "cc/layers/texture_layer_impl.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "cc/layers/quad_sink.h" 8 #include "cc/layers/quad_sink.h"
9 #include "cc/output/renderer.h" 9 #include "cc/output/renderer.h"
10 #include "cc/quads/texture_draw_quad.h" 10 #include "cc/quads/texture_draw_quad.h"
11 #include "cc/trees/layer_tree_impl.h" 11 #include "cc/trees/layer_tree_impl.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl, 15 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl,
16 int id, 16 int id,
17 bool uses_mailbox) 17 bool uses_mailbox)
18 : LayerImpl(tree_impl, id), 18 : LayerImpl(tree_impl, id),
19 uses_mailbox_(uses_mailbox),
19 texture_id_(0), 20 texture_id_(0),
20 external_texture_resource_(0), 21 external_texture_resource_(0),
21 premultiplied_alpha_(true), 22 premultiplied_alpha_(true),
22 flipped_(true), 23 flipped_(true),
23 uv_top_left_(0.f, 0.f), 24 uv_top_left_(0.f, 0.f),
24 uv_bottom_right_(1.f, 1.f), 25 uv_bottom_right_(1.f, 1.f),
25 uses_mailbox_(uses_mailbox),
26 own_mailbox_(false) { 26 own_mailbox_(false) {
27 vertex_opacity_[0] = 1.0f; 27 vertex_opacity_[0] = 1.0f;
28 vertex_opacity_[1] = 1.0f; 28 vertex_opacity_[1] = 1.0f;
29 vertex_opacity_[2] = 1.0f; 29 vertex_opacity_[2] = 1.0f;
30 vertex_opacity_[3] = 1.0f; 30 vertex_opacity_[3] = 1.0f;
31 } 31 }
32 32
33 TextureLayerImpl::~TextureLayerImpl() { FreeTextureMailbox(); } 33 TextureLayerImpl::~TextureLayerImpl() {
34 FreeTextureMailbox();
35 }
34 36
35 void TextureLayerImpl::SetTextureMailbox(const TextureMailbox& mailbox) { 37 void TextureLayerImpl::SetTextureMailbox(const TextureMailbox& mailbox) {
36 DCHECK(uses_mailbox_); 38 DCHECK(uses_mailbox_);
37 DCHECK(mailbox.IsEmpty() || !mailbox.Equals(texture_mailbox_));
piman 2013/06/05 00:30:55 Same here - leave this in?
slavi 2013/06/06 23:02:47 Done.
38 FreeTextureMailbox(); 39 FreeTextureMailbox();
39 texture_mailbox_ = mailbox; 40 texture_mailbox_ = mailbox;
40 own_mailbox_ = true; 41 own_mailbox_ = true;
41 } 42 }
42 43
43 scoped_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl( 44 scoped_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl(
44 LayerTreeImpl* tree_impl) { 45 LayerTreeImpl* tree_impl) {
45 return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_). 46 return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_).
46 PassAs<LayerImpl>(); 47 PassAs<LayerImpl>();
47 } 48 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 140
140 bool TextureLayerImpl::CanClipSelf() const { 141 bool TextureLayerImpl::CanClipSelf() const {
141 return true; 142 return true;
142 } 143 }
143 144
144 void TextureLayerImpl::DidBecomeActive() { 145 void TextureLayerImpl::DidBecomeActive() {
145 if (!own_mailbox_) 146 if (!own_mailbox_)
146 return; 147 return;
147 DCHECK(!external_texture_resource_); 148 DCHECK(!external_texture_resource_);
148 ResourceProvider* resource_provider = layer_tree_impl()->resource_provider(); 149 ResourceProvider* resource_provider = layer_tree_impl()->resource_provider();
149 if (!texture_mailbox_.IsEmpty()) { 150 if (texture_mailbox_.IsValid()) {
150 external_texture_resource_ = 151 external_texture_resource_ =
151 resource_provider->CreateResourceFromTextureMailbox(texture_mailbox_); 152 resource_provider->CreateResourceFromTextureMailbox(texture_mailbox_);
152 } 153 }
153 own_mailbox_ = false; 154 own_mailbox_ = false;
154 } 155 }
155 156
156 void TextureLayerImpl::FreeTextureMailbox() { 157 void TextureLayerImpl::FreeTextureMailbox() {
157 if (!uses_mailbox_) 158 if (!uses_mailbox_)
158 return; 159 return;
159 if (own_mailbox_) { 160 if (own_mailbox_) {
160 DCHECK(!external_texture_resource_); 161 DCHECK(!external_texture_resource_);
161 texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false); 162 texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false);
162 } else if (external_texture_resource_) { 163 } else if (external_texture_resource_) {
163 DCHECK(!own_mailbox_); 164 DCHECK(!own_mailbox_);
164 ResourceProvider* resource_provider = 165 ResourceProvider* resource_provider =
165 layer_tree_impl()->resource_provider(); 166 layer_tree_impl()->resource_provider();
166 resource_provider->DeleteResource(external_texture_resource_); 167 resource_provider->DeleteResource(external_texture_resource_);
167 external_texture_resource_ = 0; 168 external_texture_resource_ = 0;
168 } 169 }
169 } 170 }
170 171
171 } // namespace cc 172 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698