OLD | NEW |
---|---|
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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 texture_layer->set_vertex_opacity(vertex_opacity_); | 56 texture_layer->set_vertex_opacity(vertex_opacity_); |
57 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); | 57 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); |
58 if (uses_mailbox_ && own_mailbox_) { | 58 if (uses_mailbox_ && own_mailbox_) { |
59 texture_layer->SetTextureMailbox(texture_mailbox_); | 59 texture_layer->SetTextureMailbox(texture_mailbox_); |
60 own_mailbox_ = false; | 60 own_mailbox_ = false; |
61 } else { | 61 } else { |
62 texture_layer->set_texture_id(texture_id_); | 62 texture_layer->set_texture_id(texture_id_); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 void TextureLayerImpl::WillDraw(ResourceProvider* resource_provider) { | 66 bool TextureLayerImpl::WillDraw(DrawMode draw_mode, |
67 if (uses_mailbox_ || !texture_id_) | 67 ResourceProvider* resource_provider) { |
68 return; | 68 if (!texture_id_ || |
69 DCHECK(!external_texture_resource_); | 69 draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
70 external_texture_resource_ = | 70 return false; |
piman
2013/05/31 00:48:15
still nak, because if uses_mailbox_, then texture_
boliu
2013/05/31 02:50:07
Second try! Should be fixed now. The second if con
| |
71 resource_provider->CreateResourceFromExternalTexture( | 71 |
72 GL_TEXTURE_2D, | 72 if (!uses_mailbox_) { |
73 texture_id_); | 73 DCHECK(!external_texture_resource_); |
74 external_texture_resource_ = | |
75 resource_provider->CreateResourceFromExternalTexture( | |
76 GL_TEXTURE_2D, | |
77 texture_id_); | |
78 } | |
79 return LayerImpl::WillDraw(draw_mode, resource_provider); | |
74 } | 80 } |
75 | 81 |
76 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, | 82 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, |
77 AppendQuadsData* append_quads_data) { | 83 AppendQuadsData* append_quads_data) { |
78 if (!external_texture_resource_) | 84 if (!external_texture_resource_) |
79 return; | 85 return; |
80 | 86 |
81 SharedQuadState* shared_quad_state = | 87 SharedQuadState* shared_quad_state = |
82 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 88 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
83 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 89 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
(...skipping 12 matching lines...) Expand all Loading... | |
96 flipped_); | 102 flipped_); |
97 | 103 |
98 // Perform explicit clipping on a quad to avoid setting a scissor later. | 104 // Perform explicit clipping on a quad to avoid setting a scissor later. |
99 if (shared_quad_state->is_clipped && quad->PerformClipping()) | 105 if (shared_quad_state->is_clipped && quad->PerformClipping()) |
100 shared_quad_state->is_clipped = false; | 106 shared_quad_state->is_clipped = false; |
101 if (!quad->rect.IsEmpty()) | 107 if (!quad->rect.IsEmpty()) |
102 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 108 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
103 } | 109 } |
104 | 110 |
105 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { | 111 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { |
112 LayerImpl::DidDraw(resource_provider); | |
106 if (uses_mailbox_ || !external_texture_resource_) | 113 if (uses_mailbox_ || !external_texture_resource_) |
107 return; | 114 return; |
108 // FIXME: the following assert will not be true when sending resources to a | 115 // FIXME: the following assert will not be true when sending resources to a |
109 // parent compositor. A synchronization scheme (double-buffering or | 116 // parent compositor. A synchronization scheme (double-buffering or |
110 // pipelining of updates) for the client will need to exist to solve this. | 117 // pipelining of updates) for the client will need to exist to solve this. |
111 DCHECK(!resource_provider->InUseByConsumer(external_texture_resource_)); | 118 DCHECK(!resource_provider->InUseByConsumer(external_texture_resource_)); |
112 resource_provider->DeleteResource(external_texture_resource_); | 119 resource_provider->DeleteResource(external_texture_resource_); |
113 external_texture_resource_ = 0; | 120 external_texture_resource_ = 0; |
114 } | 121 } |
115 | 122 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 } else if (external_texture_resource_) { | 163 } else if (external_texture_resource_) { |
157 DCHECK(!own_mailbox_); | 164 DCHECK(!own_mailbox_); |
158 ResourceProvider* resource_provider = | 165 ResourceProvider* resource_provider = |
159 layer_tree_impl()->resource_provider(); | 166 layer_tree_impl()->resource_provider(); |
160 resource_provider->DeleteResource(external_texture_resource_); | 167 resource_provider->DeleteResource(external_texture_resource_); |
161 external_texture_resource_ = 0; | 168 external_texture_resource_ = 0; |
162 } | 169 } |
163 } | 170 } |
164 | 171 |
165 } // namespace cc | 172 } // namespace cc |
OLD | NEW |