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

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

Issue 368403003: Use RenderPass to create DrawQuad in unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layerrawptrDQ
Patch Set: address review comments Created 6 years, 5 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
« no previous file with comments | « cc/test/render_pass_test_common.cc ('k') | content/common/cc_messages_perftest.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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 gfx::Rect visible_rect = root_output_rect; 107 gfx::Rect visible_rect = root_output_rect;
108 // An invalid resource id! The resource isn't part of the frame. 108 // An invalid resource id! The resource isn't part of the frame.
109 unsigned resource_id = 5; 109 unsigned resource_id = 5;
110 bool premultiplied_alpha = false; 110 bool premultiplied_alpha = false;
111 gfx::PointF uv_top_left = gfx::PointF(0.f, 0.f); 111 gfx::PointF uv_top_left = gfx::PointF(0.f, 0.f);
112 gfx::PointF uv_bottom_right = gfx::PointF(1.f, 1.f); 112 gfx::PointF uv_bottom_right = gfx::PointF(1.f, 1.f);
113 SkColor background_color = 0; 113 SkColor background_color = 0;
114 float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; 114 float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f};
115 bool flipped = false; 115 bool flipped = false;
116 116
117 scoped_ptr<TextureDrawQuad> invalid_draw_quad = TextureDrawQuad::Create(); 117 TextureDrawQuad* invalid_draw_quad =
118 root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
118 invalid_draw_quad->SetNew(shared_quad_state, 119 invalid_draw_quad->SetNew(shared_quad_state,
119 rect, 120 rect,
120 opaque_rect, 121 opaque_rect,
121 visible_rect, 122 visible_rect,
122 resource_id, 123 resource_id,
123 premultiplied_alpha, 124 premultiplied_alpha,
124 uv_top_left, 125 uv_top_left,
125 uv_bottom_right, 126 uv_bottom_right,
126 background_color, 127 background_color,
127 vertex_opacity, 128 vertex_opacity,
128 flipped); 129 flipped);
129 root_pass->quad_list.push_back(invalid_draw_quad.PassAs<DrawQuad>());
130 130
131 frame->render_pass_list.push_back(root_pass.Pass()); 131 frame->render_pass_list.push_back(root_pass.Pass());
132 return frame.Pass(); 132 return frame.Pass();
133 } 133 }
134 134
135 void AddTransferableResource(DelegatedFrameData* frame, 135 void AddTransferableResource(DelegatedFrameData* frame,
136 ResourceProvider::ResourceId resource_id) { 136 ResourceProvider::ResourceId resource_id) {
137 TransferableResource resource; 137 TransferableResource resource;
138 resource.id = resource_id; 138 resource.id = resource_id;
139 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 139 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
140 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = { 140 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = {
141 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 141 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
142 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 142 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4,
143 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4}; 143 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4};
144 resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox); 144 resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox);
145 frame->resource_list.push_back(resource); 145 frame->resource_list.push_back(resource);
146 } 146 }
147 147
148 void AddTextureQuad(DelegatedFrameData* frame, 148 void AddTextureQuad(DelegatedFrameData* frame,
149 ResourceProvider::ResourceId resource_id) { 149 ResourceProvider::ResourceId resource_id) {
150 SharedQuadState* sqs = 150 RenderPass* render_pass = frame->render_pass_list[0];
151 frame->render_pass_list[0]->CreateAndAppendSharedQuadState(); 151 SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
152 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); 152 TextureDrawQuad* quad =
153 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
153 float vertex_opacity[4] = { 1.f, 1.f, 1.f, 1.f }; 154 float vertex_opacity[4] = { 1.f, 1.f, 1.f, 1.f };
154 quad->SetNew(sqs, 155 quad->SetNew(sqs,
155 gfx::Rect(0, 0, 10, 10), 156 gfx::Rect(0, 0, 10, 10),
156 gfx::Rect(0, 0, 10, 10), 157 gfx::Rect(0, 0, 10, 10),
157 gfx::Rect(0, 0, 10, 10), 158 gfx::Rect(0, 0, 10, 10),
158 resource_id, 159 resource_id,
159 false, 160 false,
160 gfx::PointF(0.f, 0.f), 161 gfx::PointF(0.f, 0.f),
161 gfx::PointF(1.f, 1.f), 162 gfx::PointF(1.f, 1.f),
162 SK_ColorTRANSPARENT, 163 SK_ColorTRANSPARENT,
163 vertex_opacity, 164 vertex_opacity,
164 false); 165 false);
165 frame->render_pass_list[0]->quad_list.push_back(quad.PassAs<DrawQuad>());
166 } 166 }
167 167
168 void AddRenderPass(DelegatedFrameData* frame, 168 void AddRenderPass(DelegatedFrameData* frame,
169 RenderPass::Id id, 169 RenderPass::Id id,
170 const gfx::Rect& output_rect, 170 const gfx::Rect& output_rect,
171 const gfx::Rect& damage_rect, 171 const gfx::Rect& damage_rect,
172 const FilterOperations& filters, 172 const FilterOperations& filters,
173 const FilterOperations& background_filters) { 173 const FilterOperations& background_filters) {
174 for (size_t i = 0; i < frame->render_pass_list.size(); ++i) 174 for (size_t i = 0; i < frame->render_pass_list.size(); ++i)
175 DCHECK(id != frame->render_pass_list[i]->id); 175 DCHECK(id != frame->render_pass_list[i]->id);
176 176
177 scoped_ptr<RenderPass> pass(RenderPass::Create()); 177 scoped_ptr<RenderPass> pass(RenderPass::Create());
178 pass->SetNew(id, 178 pass->SetNew(id,
179 output_rect, 179 output_rect,
180 damage_rect, 180 damage_rect,
181 gfx::Transform()); 181 gfx::Transform());
182 frame->render_pass_list.push_back(pass.Pass()); 182 frame->render_pass_list.push_back(pass.Pass());
183 183
184 SharedQuadState* sqs = 184 RenderPass* render_pass = frame->render_pass_list[0];
185 frame->render_pass_list[0]->CreateAndAppendSharedQuadState(); 185 SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
186 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create(); 186 RenderPassDrawQuad* quad =
187 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
187 188
188 quad->SetNew(sqs, 189 quad->SetNew(sqs,
189 output_rect, 190 output_rect,
190 output_rect, 191 output_rect,
191 id, 192 id,
192 false, // is_replica 193 false, // is_replica
193 0, // mask_resource_id 194 0, // mask_resource_id
194 damage_rect, 195 damage_rect,
195 gfx::Rect(0, 0, 1, 1), // mask_uv_rect 196 gfx::Rect(0, 0, 1, 1), // mask_uv_rect
196 filters, 197 filters,
197 background_filters); 198 background_filters);
198 frame->render_pass_list[0]->quad_list.push_back(quad.PassAs<DrawQuad>());
199 } 199 }
200 200
201 static ResourceProvider::ResourceId AppendResourceId( 201 static ResourceProvider::ResourceId AppendResourceId(
202 std::vector<ResourceProvider::ResourceId>* resources_in_last_sent_frame, 202 std::vector<ResourceProvider::ResourceId>* resources_in_last_sent_frame,
203 ResourceProvider::ResourceId resource_id) { 203 ResourceProvider::ResourceId resource_id) {
204 resources_in_last_sent_frame->push_back(resource_id); 204 resources_in_last_sent_frame->push_back(resource_id);
205 return resource_id; 205 return resource_id;
206 } 206 }
207 207
208 void ReturnUnusedResourcesFromParent(LayerTreeHostImpl* host_impl) { 208 void ReturnUnusedResourcesFromParent(LayerTreeHostImpl* host_impl) {
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 } 2193 }
2194 2194
2195 scoped_refptr<DelegatedRendererLayer> delegated_thief_; 2195 scoped_refptr<DelegatedRendererLayer> delegated_thief_;
2196 }; 2196 };
2197 2197
2198 SINGLE_AND_MULTI_THREAD_TEST_F( 2198 SINGLE_AND_MULTI_THREAD_TEST_F(
2199 LayerTreeHostDelegatedTestRemoveAndChangeResources); 2199 LayerTreeHostDelegatedTestRemoveAndChangeResources);
2200 2200
2201 } // namespace 2201 } // namespace
2202 } // namespace cc 2202 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/render_pass_test_common.cc ('k') | content/common/cc_messages_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698