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

Side by Side Diff: cc/texture_layer_impl.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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
« no previous file with comments | « cc/texture_layer_impl.h ('k') | cc/texture_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/texture_layer_impl.h" 5 #include "cc/texture_layer_impl.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "cc/layer_tree_impl.h" 8 #include "cc/layer_tree_impl.h"
9 #include "cc/quad_sink.h" 9 #include "cc/quad_sink.h"
10 #include "cc/renderer.h" 10 #include "cc/renderer.h"
(...skipping 25 matching lines...) Expand all
36 36
37 void TextureLayerImpl::setTextureMailbox(const TextureMailbox& mailbox) 37 void TextureLayerImpl::setTextureMailbox(const TextureMailbox& mailbox)
38 { 38 {
39 DCHECK(m_usesMailbox); 39 DCHECK(m_usesMailbox);
40 DCHECK(mailbox.IsEmpty() || !mailbox.Equals(m_textureMailbox)); 40 DCHECK(mailbox.IsEmpty() || !mailbox.Equals(m_textureMailbox));
41 freeTextureMailbox(); 41 freeTextureMailbox();
42 m_textureMailbox = mailbox; 42 m_textureMailbox = mailbox;
43 m_ownMailbox = true; 43 m_ownMailbox = true;
44 } 44 }
45 45
46 scoped_ptr<LayerImpl> TextureLayerImpl::createLayerImpl(LayerTreeImpl* treeImpl) 46 scoped_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl(LayerTreeImpl* treeImpl)
47 { 47 {
48 return TextureLayerImpl::create(treeImpl, id(), m_usesMailbox).PassAs<LayerI mpl>(); 48 return TextureLayerImpl::Create(treeImpl, id(), m_usesMailbox).PassAs<LayerI mpl>();
49 } 49 }
50 50
51 void TextureLayerImpl::pushPropertiesTo(LayerImpl* layer) 51 void TextureLayerImpl::PushPropertiesTo(LayerImpl* layer)
52 { 52 {
53 LayerImpl::pushPropertiesTo(layer); 53 LayerImpl::PushPropertiesTo(layer);
54 54
55 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer); 55 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer);
56 textureLayer->setFlipped(m_flipped); 56 textureLayer->setFlipped(m_flipped);
57 textureLayer->setUVTopLeft(m_uvTopLeft); 57 textureLayer->setUVTopLeft(m_uvTopLeft);
58 textureLayer->setUVBottomRight(m_uvBottomRight); 58 textureLayer->setUVBottomRight(m_uvBottomRight);
59 textureLayer->setVertexOpacity(m_vertexOpacity); 59 textureLayer->setVertexOpacity(m_vertexOpacity);
60 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); 60 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
61 if (m_usesMailbox && m_ownMailbox) { 61 if (m_usesMailbox && m_ownMailbox) {
62 textureLayer->setTextureMailbox(m_textureMailbox); 62 textureLayer->setTextureMailbox(m_textureMailbox);
63 m_ownMailbox = false; 63 m_ownMailbox = false;
64 } else { 64 } else {
65 textureLayer->setTextureId(m_textureId); 65 textureLayer->setTextureId(m_textureId);
66 } 66 }
67 } 67 }
68 68
69 69
70 void TextureLayerImpl::willDraw(ResourceProvider* resourceProvider) 70 void TextureLayerImpl::WillDraw(ResourceProvider* resourceProvider)
71 { 71 {
72 if (m_usesMailbox || !m_textureId) 72 if (m_usesMailbox || !m_textureId)
73 return; 73 return;
74 DCHECK(!m_externalTextureResource); 74 DCHECK(!m_externalTextureResource);
75 m_externalTextureResource = resourceProvider->CreateResourceFromExternalText ure(m_textureId); 75 m_externalTextureResource = resourceProvider->CreateResourceFromExternalText ure(m_textureId);
76 } 76 }
77 77
78 void TextureLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQu adsData) 78 void TextureLayerImpl::AppendQuads(QuadSink* quadSink, AppendQuadsData* appendQu adsData)
79 { 79 {
80 if (!m_externalTextureResource) 80 if (!m_externalTextureResource)
81 return; 81 return;
82 82
83 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); 83 SharedQuadState* sharedQuadState = quadSink->useSharedQuadState(CreateShared QuadState());
84 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); 84 AppendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
85 85
86 gfx::Rect quadRect(gfx::Point(), contentBounds()); 86 gfx::Rect quadRect(content_bounds());
87 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); 87 gfx::Rect opaqueRect(contents_opaque() ? quadRect : gfx::Rect());
88 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); 88 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
89 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_externalTextureResourc e, m_premultipliedAlpha, m_uvTopLeft, m_uvBottomRight, m_vertexOpacity, m_flippe d); 89 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_externalTextureResourc e, m_premultipliedAlpha, m_uvTopLeft, m_uvBottomRight, m_vertexOpacity, m_flippe d);
90 90
91 // Perform explicit clipping on a quad to avoid setting a scissor later. 91 // Perform explicit clipping on a quad to avoid setting a scissor later.
92 if (sharedQuadState->is_clipped && quad->PerformClipping()) 92 if (sharedQuadState->is_clipped && quad->PerformClipping())
93 sharedQuadState->is_clipped = false; 93 sharedQuadState->is_clipped = false;
94 if (!quad->rect.IsEmpty()) 94 if (!quad->rect.IsEmpty())
95 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 95 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData);
96 } 96 }
97 97
98 void TextureLayerImpl::didDraw(ResourceProvider* resourceProvider) 98 void TextureLayerImpl::DidDraw(ResourceProvider* resourceProvider)
99 { 99 {
100 if (m_usesMailbox || !m_externalTextureResource) 100 if (m_usesMailbox || !m_externalTextureResource)
101 return; 101 return;
102 // FIXME: the following assert will not be true when sending resources to a 102 // FIXME: the following assert will not be true when sending resources to a
103 // parent compositor. A synchronization scheme (double-buffering or 103 // parent compositor. A synchronization scheme (double-buffering or
104 // pipelining of updates) for the client will need to exist to solve this. 104 // pipelining of updates) for the client will need to exist to solve this.
105 DCHECK(!resourceProvider->InUseByConsumer(m_externalTextureResource)); 105 DCHECK(!resourceProvider->InUseByConsumer(m_externalTextureResource));
106 resourceProvider->DeleteResource(m_externalTextureResource); 106 resourceProvider->DeleteResource(m_externalTextureResource);
107 m_externalTextureResource = 0; 107 m_externalTextureResource = 0;
108 } 108 }
109 109
110 void TextureLayerImpl::dumpLayerProperties(std::string* str, int indent) const 110 void TextureLayerImpl::DumpLayerProperties(std::string* str, int indent) const
111 { 111 {
112 str->append(indentString(indent)); 112 str->append(IndentString(indent));
113 base::StringAppendF(str, "texture layer texture id: %u premultiplied: %d\n", m_textureId, m_premultipliedAlpha); 113 base::StringAppendF(str, "texture layer texture id: %u premultiplied: %d\n", m_textureId, m_premultipliedAlpha);
114 LayerImpl::dumpLayerProperties(str, indent); 114 LayerImpl::DumpLayerProperties(str, indent);
115 } 115 }
116 116
117 void TextureLayerImpl::setVertexOpacity(const float vertexOpacity[4]) { 117 void TextureLayerImpl::setVertexOpacity(const float vertexOpacity[4]) {
118 m_vertexOpacity[0] = vertexOpacity[0]; 118 m_vertexOpacity[0] = vertexOpacity[0];
119 m_vertexOpacity[1] = vertexOpacity[1]; 119 m_vertexOpacity[1] = vertexOpacity[1];
120 m_vertexOpacity[2] = vertexOpacity[2]; 120 m_vertexOpacity[2] = vertexOpacity[2];
121 m_vertexOpacity[3] = vertexOpacity[3]; 121 m_vertexOpacity[3] = vertexOpacity[3];
122 } 122 }
123 123
124 void TextureLayerImpl::didLoseOutputSurface() 124 void TextureLayerImpl::DidLoseOutputSurface()
125 { 125 {
126 m_textureId = 0; 126 m_textureId = 0;
127 m_externalTextureResource = 0; 127 m_externalTextureResource = 0;
128 } 128 }
129 129
130 const char* TextureLayerImpl::layerTypeAsString() const 130 const char* TextureLayerImpl::LayerTypeAsString() const
131 { 131 {
132 return "TextureLayer"; 132 return "TextureLayer";
133 } 133 }
134 134
135 bool TextureLayerImpl::canClipSelf() const 135 bool TextureLayerImpl::CanClipSelf() const
136 { 136 {
137 return true; 137 return true;
138 } 138 }
139 139
140 void TextureLayerImpl::didBecomeActive() 140 void TextureLayerImpl::DidBecomeActive()
141 { 141 {
142 if (!m_ownMailbox) 142 if (!m_ownMailbox)
143 return; 143 return;
144 DCHECK(!m_externalTextureResource); 144 DCHECK(!m_externalTextureResource);
145 ResourceProvider* resourceProvider = layerTreeImpl()->resource_provider(); 145 ResourceProvider* resourceProvider = layer_tree_impl()->resource_provider();
146 if (!m_textureMailbox.IsEmpty()) 146 if (!m_textureMailbox.IsEmpty())
147 m_externalTextureResource = resourceProvider->CreateResourceFromTextureM ailbox(m_textureMailbox); 147 m_externalTextureResource = resourceProvider->CreateResourceFromTextureM ailbox(m_textureMailbox);
148 m_ownMailbox = false; 148 m_ownMailbox = false;
149 } 149 }
150 150
151 void TextureLayerImpl::freeTextureMailbox() 151 void TextureLayerImpl::freeTextureMailbox()
152 { 152 {
153 if (!m_usesMailbox) 153 if (!m_usesMailbox)
154 return; 154 return;
155 if (m_ownMailbox) { 155 if (m_ownMailbox) {
156 DCHECK(!m_externalTextureResource); 156 DCHECK(!m_externalTextureResource);
157 m_textureMailbox.RunReleaseCallback(m_textureMailbox.sync_point()); 157 m_textureMailbox.RunReleaseCallback(m_textureMailbox.sync_point());
158 } else if (m_externalTextureResource) { 158 } else if (m_externalTextureResource) {
159 DCHECK(!m_ownMailbox); 159 DCHECK(!m_ownMailbox);
160 ResourceProvider* resourceProvider = layerTreeImpl()->resource_provider( ); 160 ResourceProvider* resourceProvider = layer_tree_impl()->resource_provide r();
161 resourceProvider->DeleteResource(m_externalTextureResource); 161 resourceProvider->DeleteResource(m_externalTextureResource);
162 m_externalTextureResource = 0; 162 m_externalTextureResource = 0;
163 } 163 }
164 } 164 }
165 165
166 } // namespace cc 166 } // namespace cc
OLDNEW
« no previous file with comments | « cc/texture_layer_impl.h ('k') | cc/texture_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698