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 (uses_mailbox_ || !texture_id_ || |
69 draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | |
70 return false; | |
piman
2013/05/30 22:18:18
if uses_mailbox_ and we're not in DRAW_MODE_RESOUR
boliu
2013/05/31 00:09:08
Done.
| |
69 DCHECK(!external_texture_resource_); | 71 DCHECK(!external_texture_resource_); |
70 external_texture_resource_ = | 72 external_texture_resource_ = |
71 resource_provider->CreateResourceFromExternalTexture( | 73 resource_provider->CreateResourceFromExternalTexture( |
72 GL_TEXTURE_2D, | 74 GL_TEXTURE_2D, |
73 texture_id_); | 75 texture_id_); |
76 return LayerImpl::WillDraw(draw_mode, resource_provider); | |
74 } | 77 } |
75 | 78 |
76 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, | 79 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, |
77 AppendQuadsData* append_quads_data) { | 80 AppendQuadsData* append_quads_data) { |
78 if (!external_texture_resource_) | 81 if (!external_texture_resource_) |
79 return; | 82 return; |
80 | 83 |
81 SharedQuadState* shared_quad_state = | 84 SharedQuadState* shared_quad_state = |
82 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 85 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
83 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 86 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
(...skipping 12 matching lines...) Expand all Loading... | |
96 flipped_); | 99 flipped_); |
97 | 100 |
98 // Perform explicit clipping on a quad to avoid setting a scissor later. | 101 // Perform explicit clipping on a quad to avoid setting a scissor later. |
99 if (shared_quad_state->is_clipped && quad->PerformClipping()) | 102 if (shared_quad_state->is_clipped && quad->PerformClipping()) |
100 shared_quad_state->is_clipped = false; | 103 shared_quad_state->is_clipped = false; |
101 if (!quad->rect.IsEmpty()) | 104 if (!quad->rect.IsEmpty()) |
102 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 105 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
103 } | 106 } |
104 | 107 |
105 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { | 108 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { |
109 LayerImpl::DidDraw(resource_provider); | |
106 if (uses_mailbox_ || !external_texture_resource_) | 110 if (uses_mailbox_ || !external_texture_resource_) |
107 return; | 111 return; |
108 // FIXME: the following assert will not be true when sending resources to a | 112 // FIXME: the following assert will not be true when sending resources to a |
109 // parent compositor. A synchronization scheme (double-buffering or | 113 // parent compositor. A synchronization scheme (double-buffering or |
110 // pipelining of updates) for the client will need to exist to solve this. | 114 // pipelining of updates) for the client will need to exist to solve this. |
111 DCHECK(!resource_provider->InUseByConsumer(external_texture_resource_)); | 115 DCHECK(!resource_provider->InUseByConsumer(external_texture_resource_)); |
112 resource_provider->DeleteResource(external_texture_resource_); | 116 resource_provider->DeleteResource(external_texture_resource_); |
113 external_texture_resource_ = 0; | 117 external_texture_resource_ = 0; |
114 } | 118 } |
115 | 119 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 } else if (external_texture_resource_) { | 160 } else if (external_texture_resource_) { |
157 DCHECK(!own_mailbox_); | 161 DCHECK(!own_mailbox_); |
158 ResourceProvider* resource_provider = | 162 ResourceProvider* resource_provider = |
159 layer_tree_impl()->resource_provider(); | 163 layer_tree_impl()->resource_provider(); |
160 resource_provider->DeleteResource(external_texture_resource_); | 164 resource_provider->DeleteResource(external_texture_resource_); |
161 external_texture_resource_ = 0; | 165 external_texture_resource_ = 0; |
162 } | 166 } |
163 } | 167 } |
164 | 168 |
165 } // namespace cc | 169 } // namespace cc |
OLD | NEW |