OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/cc_messages.h" | 5 #include "content/common/cc_messages.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
| 9 #include "base/command_line.h" |
9 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "content/public/common/content_switches.h" |
10 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
12 | 15 |
13 using cc::CheckerboardDrawQuad; | 16 using cc::CheckerboardDrawQuad; |
14 using cc::DelegatedFrameData; | 17 using cc::DelegatedFrameData; |
15 using cc::DebugBorderDrawQuad; | 18 using cc::DebugBorderDrawQuad; |
16 using cc::DrawQuad; | 19 using cc::DrawQuad; |
17 using cc::FilterOperation; | 20 using cc::FilterOperation; |
18 using cc::FilterOperations; | 21 using cc::FilterOperations; |
19 using cc::IOSurfaceDrawQuad; | 22 using cc::IOSurfaceDrawQuad; |
20 using cc::PictureDrawQuad; | 23 using cc::PictureDrawQuad; |
21 using cc::RenderPass; | 24 using cc::RenderPass; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 130 } |
128 | 131 |
129 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { | 132 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { |
130 EXPECT_EQ(a->render_pass_id, b->render_pass_id); | 133 EXPECT_EQ(a->render_pass_id, b->render_pass_id); |
131 EXPECT_EQ(a->is_replica, b->is_replica); | 134 EXPECT_EQ(a->is_replica, b->is_replica); |
132 EXPECT_EQ(a->mask_resource_id, b->mask_resource_id); | 135 EXPECT_EQ(a->mask_resource_id, b->mask_resource_id); |
133 EXPECT_EQ(a->contents_changed_since_last_frame, | 136 EXPECT_EQ(a->contents_changed_since_last_frame, |
134 b->contents_changed_since_last_frame); | 137 b->contents_changed_since_last_frame); |
135 EXPECT_EQ(a->mask_uv_rect.ToString(), b->mask_uv_rect.ToString()); | 138 EXPECT_EQ(a->mask_uv_rect.ToString(), b->mask_uv_rect.ToString()); |
136 EXPECT_EQ(a->filters, b->filters); | 139 EXPECT_EQ(a->filters, b->filters); |
137 EXPECT_EQ(a->filter, b->filter); | 140 if (!a->filter || !b->filter) |
| 141 EXPECT_EQ(a->filter, b->filter); |
| 142 else |
| 143 EXPECT_EQ(a->filter->countInputs(), b->filter->countInputs()); |
138 EXPECT_EQ(a->background_filters, b->background_filters); | 144 EXPECT_EQ(a->background_filters, b->background_filters); |
139 } | 145 } |
140 | 146 |
141 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { | 147 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { |
142 EXPECT_EQ(a->color, b->color); | 148 EXPECT_EQ(a->color, b->color); |
143 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); | 149 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); |
144 } | 150 } |
145 | 151 |
146 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { | 152 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { |
147 EXPECT_EQ(a->resource_id, b->resource_id); | 153 EXPECT_EQ(a->resource_id, b->resource_id); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 EXPECT_EQ(a.sync_point, b.sync_point); | 187 EXPECT_EQ(a.sync_point, b.sync_point); |
182 EXPECT_EQ(a.format, b.format); | 188 EXPECT_EQ(a.format, b.format); |
183 EXPECT_EQ(a.filter, b.filter); | 189 EXPECT_EQ(a.filter, b.filter); |
184 EXPECT_EQ(a.size.ToString(), b.size.ToString()); | 190 EXPECT_EQ(a.size.ToString(), b.size.ToString()); |
185 for (size_t i = 0; i < arraysize(a.mailbox.name); ++i) | 191 for (size_t i = 0; i < arraysize(a.mailbox.name); ++i) |
186 EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]); | 192 EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]); |
187 } | 193 } |
188 }; | 194 }; |
189 | 195 |
190 TEST_F(CCMessagesTest, AllQuads) { | 196 TEST_F(CCMessagesTest, AllQuads) { |
| 197 CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 198 if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC)) |
| 199 command_line.AppendSwitch(switches::kAllowFiltersOverIPC); |
| 200 |
191 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 201 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
192 | 202 |
193 Transform arbitrary_matrix; | 203 Transform arbitrary_matrix; |
194 arbitrary_matrix.Scale(3, 3); | 204 arbitrary_matrix.Scale(3, 3); |
195 arbitrary_matrix.Translate(-5, 20); | 205 arbitrary_matrix.Translate(-5, 20); |
196 arbitrary_matrix.Rotate(15); | 206 arbitrary_matrix.Rotate(15); |
197 gfx::Rect arbitrary_rect1(-5, 9, 3, 15); | 207 gfx::Rect arbitrary_rect1(-5, 9, 3, 15); |
198 gfx::Rect arbitrary_rect2(40, 23, 11, 7); | 208 gfx::Rect arbitrary_rect2(40, 23, 11, 7); |
199 gfx::Rect arbitrary_rect3(7, -53, 22, 19); | 209 gfx::Rect arbitrary_rect3(7, -53, 22, 19); |
200 gfx::Size arbitrary_size1(15, 19); | 210 gfx::Size arbitrary_size1(15, 19); |
(...skipping 12 matching lines...) Expand all Loading... |
213 bool arbitrary_bool3 = true; | 223 bool arbitrary_bool3 = true; |
214 int arbitrary_int = 5; | 224 int arbitrary_int = 5; |
215 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); | 225 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); |
216 IOSurfaceDrawQuad::Orientation arbitrary_orientation = | 226 IOSurfaceDrawQuad::Orientation arbitrary_orientation = |
217 IOSurfaceDrawQuad::UNFLIPPED; | 227 IOSurfaceDrawQuad::UNFLIPPED; |
218 RenderPass::Id arbitrary_id(10, 14); | 228 RenderPass::Id arbitrary_id(10, 14); |
219 ResourceProvider::ResourceId arbitrary_resourceid1 = 55; | 229 ResourceProvider::ResourceId arbitrary_resourceid1 = 55; |
220 ResourceProvider::ResourceId arbitrary_resourceid2 = 47; | 230 ResourceProvider::ResourceId arbitrary_resourceid2 = 47; |
221 ResourceProvider::ResourceId arbitrary_resourceid3 = 23; | 231 ResourceProvider::ResourceId arbitrary_resourceid3 = 23; |
222 ResourceProvider::ResourceId arbitrary_resourceid4 = 16; | 232 ResourceProvider::ResourceId arbitrary_resourceid4 = 16; |
| 233 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f); |
223 | 234 |
224 FilterOperations arbitrary_filters1; | 235 FilterOperations arbitrary_filters1; |
225 arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter( | 236 arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter( |
226 arbitrary_float1)); | 237 arbitrary_float1)); |
227 | 238 |
228 FilterOperations arbitrary_filters2; | 239 FilterOperations arbitrary_filters2; |
229 arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter( | 240 arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter( |
230 arbitrary_float2)); | 241 arbitrary_float2)); |
231 | 242 |
232 // TODO(danakj): filter is not serialized. | 243 skia::RefPtr<SkImageFilter> arbitrary_filter = skia::AdoptRef( |
233 skia::RefPtr<SkImageFilter> arbitrary_filter; | 244 new SkBlurImageFilter(arbitrary_sigma, arbitrary_sigma)); |
234 | 245 |
235 scoped_ptr<SharedQuadState> shared_state1_in = SharedQuadState::Create(); | 246 scoped_ptr<SharedQuadState> shared_state1_in = SharedQuadState::Create(); |
236 shared_state1_in->SetAll(arbitrary_matrix, | 247 shared_state1_in->SetAll(arbitrary_matrix, |
237 arbitrary_size1, | 248 arbitrary_size1, |
238 arbitrary_rect1, | 249 arbitrary_rect1, |
239 arbitrary_rect2, | 250 arbitrary_rect2, |
240 arbitrary_bool1, | 251 arbitrary_bool1, |
241 arbitrary_float1); | 252 arbitrary_float1); |
242 scoped_ptr<SharedQuadState> shared_state1_cmp = shared_state1_in->Copy(); | 253 scoped_ptr<SharedQuadState> shared_state1_cmp = shared_state1_in->Copy(); |
243 | 254 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 arbitrary_rect1, | 294 arbitrary_rect1, |
284 arbitrary_rect2, | 295 arbitrary_rect2, |
285 arbitrary_rect3, | 296 arbitrary_rect3, |
286 arbitrary_bool1, | 297 arbitrary_bool1, |
287 arbitrary_id, | 298 arbitrary_id, |
288 arbitrary_bool2, | 299 arbitrary_bool2, |
289 arbitrary_resourceid2, | 300 arbitrary_resourceid2, |
290 arbitrary_rect1, | 301 arbitrary_rect1, |
291 arbitrary_rectf1, | 302 arbitrary_rectf1, |
292 arbitrary_filters1, | 303 arbitrary_filters1, |
293 arbitrary_filter, // TODO(piman): not serialized. | 304 arbitrary_filter, |
294 arbitrary_filters2); | 305 arbitrary_filters2); |
295 scoped_ptr<RenderPassDrawQuad> renderpass_cmp = renderpass_in->Copy( | 306 scoped_ptr<RenderPassDrawQuad> renderpass_cmp = renderpass_in->Copy( |
296 renderpass_in->shared_quad_state, renderpass_in->render_pass_id); | 307 renderpass_in->shared_quad_state, renderpass_in->render_pass_id); |
297 | 308 |
298 scoped_ptr<SharedQuadState> shared_state2_in = SharedQuadState::Create(); | 309 scoped_ptr<SharedQuadState> shared_state2_in = SharedQuadState::Create(); |
299 shared_state2_in->SetAll(arbitrary_matrix, | 310 shared_state2_in->SetAll(arbitrary_matrix, |
300 arbitrary_size2, | 311 arbitrary_size2, |
301 arbitrary_rect2, | 312 arbitrary_rect2, |
302 arbitrary_rect3, | 313 arbitrary_rect3, |
303 arbitrary_bool1, | 314 arbitrary_bool1, |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, | 534 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, |
524 &iter, &frame_out)); | 535 &iter, &frame_out)); |
525 | 536 |
526 ASSERT_EQ(2u, frame_out.resource_list.size()); | 537 ASSERT_EQ(2u, frame_out.resource_list.size()); |
527 Compare(arbitrary_resource1, frame_out.resource_list[0]); | 538 Compare(arbitrary_resource1, frame_out.resource_list[0]); |
528 Compare(arbitrary_resource2, frame_out.resource_list[1]); | 539 Compare(arbitrary_resource2, frame_out.resource_list[1]); |
529 } | 540 } |
530 | 541 |
531 } // namespace | 542 } // namespace |
532 } // namespace content | 543 } // namespace content |
OLD | NEW |