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

Side by Side Diff: cc/trees/layer_tree_host_unittest_delegated.cc

Issue 1144523003: Rename cc::ResourceProvider::ResourceId to cc::ResourceId and move it to its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 background_color, 128 background_color,
129 vertex_opacity, 129 vertex_opacity,
130 flipped, 130 flipped,
131 nearest_neighbor); 131 nearest_neighbor);
132 132
133 frame->render_pass_list.push_back(root_pass.Pass()); 133 frame->render_pass_list.push_back(root_pass.Pass());
134 return frame.Pass(); 134 return frame.Pass();
135 } 135 }
136 136
137 void AddTransferableResource(DelegatedFrameData* frame, 137 void AddTransferableResource(DelegatedFrameData* frame,
138 ResourceProvider::ResourceId resource_id) { 138 ResourceId resource_id) {
139 TransferableResource resource; 139 TransferableResource resource;
140 resource.id = resource_id; 140 resource.id = resource_id;
141 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 141 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
142 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = { 142 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = {
143 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 143 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
144 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 144 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4,
145 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4}; 145 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4};
146 resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox); 146 resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox);
147 frame->resource_list.push_back(resource); 147 frame->resource_list.push_back(resource);
148 } 148 }
149 149
150 void AddTextureQuad(DelegatedFrameData* frame, 150 void AddTextureQuad(DelegatedFrameData* frame, ResourceId resource_id) {
151 ResourceProvider::ResourceId resource_id) {
152 RenderPass* render_pass = frame->render_pass_list[0]; 151 RenderPass* render_pass = frame->render_pass_list[0];
153 SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState(); 152 SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
154 TextureDrawQuad* quad = 153 TextureDrawQuad* quad =
155 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 154 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
156 float vertex_opacity[4] = { 1.f, 1.f, 1.f, 1.f }; 155 float vertex_opacity[4] = { 1.f, 1.f, 1.f, 1.f };
157 quad->SetNew(sqs, 156 quad->SetNew(sqs,
158 gfx::Rect(0, 0, 10, 10), 157 gfx::Rect(0, 0, 10, 10),
159 gfx::Rect(0, 0, 10, 10), 158 gfx::Rect(0, 0, 10, 10),
160 gfx::Rect(0, 0, 10, 10), 159 gfx::Rect(0, 0, 10, 10),
161 resource_id, 160 resource_id,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 output_rect, 193 output_rect,
195 id, 194 id,
196 0, 195 0,
197 gfx::Vector2dF(), 196 gfx::Vector2dF(),
198 gfx::Size(), 197 gfx::Size(),
199 filters, 198 filters,
200 gfx::Vector2dF(), 199 gfx::Vector2dF(),
201 background_filters); 200 background_filters);
202 } 201 }
203 202
204 static ResourceProvider::ResourceId AppendResourceId( 203 static ResourceId AppendResourceId(
205 std::vector<ResourceProvider::ResourceId>* resources_in_last_sent_frame, 204 std::vector<ResourceId>* resources_in_last_sent_frame,
206 ResourceProvider::ResourceId resource_id) { 205 ResourceId resource_id) {
207 resources_in_last_sent_frame->push_back(resource_id); 206 resources_in_last_sent_frame->push_back(resource_id);
208 return resource_id; 207 return resource_id;
209 } 208 }
210 209
211 void ReturnUnusedResourcesFromParent(LayerTreeHostImpl* host_impl) { 210 void ReturnUnusedResourcesFromParent(LayerTreeHostImpl* host_impl) {
212 DelegatedFrameData* delegated_frame_data = 211 DelegatedFrameData* delegated_frame_data =
213 output_surface()->last_sent_frame().delegated_frame_data.get(); 212 output_surface()->last_sent_frame().delegated_frame_data.get();
214 if (!delegated_frame_data) 213 if (!delegated_frame_data)
215 return; 214 return;
216 215
217 std::vector<ResourceProvider::ResourceId> resources_in_last_sent_frame; 216 std::vector<ResourceId> resources_in_last_sent_frame;
218 for (size_t i = 0; i < delegated_frame_data->resource_list.size(); ++i) { 217 for (size_t i = 0; i < delegated_frame_data->resource_list.size(); ++i) {
219 resources_in_last_sent_frame.push_back( 218 resources_in_last_sent_frame.push_back(
220 delegated_frame_data->resource_list[i].id); 219 delegated_frame_data->resource_list[i].id);
221 } 220 }
222 221
223 std::vector<ResourceProvider::ResourceId> resources_to_return; 222 std::vector<ResourceId> resources_to_return;
224 223
225 const TransferableResourceArray& resources_held_by_parent = 224 const TransferableResourceArray& resources_held_by_parent =
226 output_surface()->resources_held_by_parent(); 225 output_surface()->resources_held_by_parent();
227 for (size_t i = 0; i < resources_held_by_parent.size(); ++i) { 226 for (size_t i = 0; i < resources_held_by_parent.size(); ++i) {
228 ResourceProvider::ResourceId resource_in_parent = 227 ResourceId resource_in_parent = resources_held_by_parent[i].id;
229 resources_held_by_parent[i].id;
230 bool resource_in_parent_is_not_part_of_frame = 228 bool resource_in_parent_is_not_part_of_frame =
231 std::find(resources_in_last_sent_frame.begin(), 229 std::find(resources_in_last_sent_frame.begin(),
232 resources_in_last_sent_frame.end(), 230 resources_in_last_sent_frame.end(),
233 resource_in_parent) == resources_in_last_sent_frame.end(); 231 resource_in_parent) == resources_in_last_sent_frame.end();
234 if (resource_in_parent_is_not_part_of_frame) 232 if (resource_in_parent_is_not_part_of_frame)
235 resources_to_return.push_back(resource_in_parent); 233 resources_to_return.push_back(resource_in_parent);
236 } 234 }
237 235
238 if (resources_to_return.empty()) 236 if (resources_to_return.empty())
239 return; 237 return;
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 764
767 const ResourceProvider::ResourceIdMap& map = 765 const ResourceProvider::ResourceIdMap& map =
768 host_impl->resource_provider()->GetChildToParentMap( 766 host_impl->resource_provider()->GetChildToParentMap(
769 delegated_impl->ChildId()); 767 delegated_impl->ChildId());
770 768
771 // The frame's resource should be in the parent's resource provider. 769 // The frame's resource should be in the parent's resource provider.
772 EXPECT_EQ(2u, map.size()); 770 EXPECT_EQ(2u, map.size());
773 EXPECT_EQ(1u, map.count(999)); 771 EXPECT_EQ(1u, map.count(999));
774 EXPECT_EQ(1u, map.count(555)); 772 EXPECT_EQ(1u, map.count(555));
775 773
776 ResourceProvider::ResourceId parent_resource_id1 = map.find(999)->second; 774 ResourceId parent_resource_id1 = map.find(999)->second;
777 EXPECT_NE(parent_resource_id1, 999u); 775 EXPECT_NE(parent_resource_id1, 999u);
778 ResourceProvider::ResourceId parent_resource_id2 = map.find(555)->second; 776 ResourceId parent_resource_id2 = map.find(555)->second;
779 EXPECT_NE(parent_resource_id2, 555u); 777 EXPECT_NE(parent_resource_id2, 555u);
780 778
781 // The resources in the quads should be remapped to the parent's namespace. 779 // The resources in the quads should be remapped to the parent's namespace.
782 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast( 780 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast(
783 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.ElementAt(0)); 781 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.ElementAt(0));
784 EXPECT_EQ(parent_resource_id1, quad1->resource_id); 782 EXPECT_EQ(parent_resource_id1, quad1->resource_id);
785 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast( 783 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast(
786 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.ElementAt(1)); 784 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.ElementAt(1));
787 EXPECT_EQ(parent_resource_id2, quad2->resource_id); 785 EXPECT_EQ(parent_resource_id2, quad2->resource_id);
788 786
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 ReturnAllResourcesFromParent(host_impl); 2252 ReturnAllResourcesFromParent(host_impl);
2255 } 2253 }
2256 2254
2257 bool drew_with_pending_tree_; 2255 bool drew_with_pending_tree_;
2258 }; 2256 };
2259 2257
2260 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid); 2258 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid);
2261 2259
2262 } // namespace 2260 } // namespace
2263 } // namespace cc 2261 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698