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

Side by Side Diff: components/mus/public/cpp/surfaces/tests/surface_unittest.cc

Issue 2028573003: Implement gfx::Transform StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing build file Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "cc/quads/debug_border_draw_quad.h" 10 #include "cc/quads/debug_border_draw_quad.h"
11 #include "cc/quads/render_pass.h" 11 #include "cc/quads/render_pass.h"
12 #include "cc/quads/solid_color_draw_quad.h" 12 #include "cc/quads/solid_color_draw_quad.h"
13 #include "cc/quads/surface_draw_quad.h" 13 #include "cc/quads/surface_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h" 14 #include "cc/quads/texture_draw_quad.h"
15 #include "cc/resources/resource_provider.h" 15 #include "cc/resources/resource_provider.h"
16 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" 16 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h"
17 #include "gpu/command_buffer/common/mailbox.h" 17 #include "gpu/command_buffer/common/mailbox.h"
18 #include "gpu/command_buffer/common/mailbox_holder.h" 18 #include "gpu/command_buffer/common/mailbox_holder.h"
19 #include "gpu/command_buffer/common/sync_token.h" 19 #include "gpu/command_buffer/common/sync_token.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
22 #include "third_party/skia/include/core/SkXfermode.h" 22 #include "third_party/skia/include/core/SkXfermode.h"
23 #include "ui/gfx/mojo/transform_type_converters.h"
24 23
25 using mus::mojom::Color; 24 using mus::mojom::Color;
26 using mus::mojom::ColorPtr; 25 using mus::mojom::ColorPtr;
27 using mus::mojom::CompositorFrame; 26 using mus::mojom::CompositorFrame;
28 using mus::mojom::CompositorFramePtr; 27 using mus::mojom::CompositorFramePtr;
29 using mus::mojom::CompositorFrameMetadata; 28 using mus::mojom::CompositorFrameMetadata;
30 using mus::mojom::CompositorFrameMetadataPtr; 29 using mus::mojom::CompositorFrameMetadataPtr;
31 using mus::mojom::DebugBorderQuadState; 30 using mus::mojom::DebugBorderQuadState;
32 using mus::mojom::DebugBorderQuadStatePtr; 31 using mus::mojom::DebugBorderQuadStatePtr;
33 using mus::mojom::Pass; 32 using mus::mojom::Pass;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 int sorting_context_id = 13; 209 int sorting_context_id = 13;
211 ::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode; 210 ::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode;
212 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 211 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
213 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 212 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
214 sqs->SetAll(quad_to_target_transform, quad_layer_bounds, 213 sqs->SetAll(quad_to_target_transform, quad_layer_bounds,
215 visible_quad_layer_rect, clip_rect, is_clipped, opacity, 214 visible_quad_layer_rect, clip_rect, is_clipped, opacity,
216 blend_mode, sorting_context_id); 215 blend_mode, sorting_context_id);
217 216
218 SharedQuadStatePtr mus_sqs = SharedQuadState::From(*sqs); 217 SharedQuadStatePtr mus_sqs = SharedQuadState::From(*sqs);
219 ASSERT_FALSE(mus_sqs.is_null()); 218 ASSERT_FALSE(mus_sqs.is_null());
220 EXPECT_TRUE(Transform::From(quad_to_target_transform) 219 EXPECT_EQ(quad_to_target_transform, mus_sqs->quad_to_target_transform);
221 .Equals(mus_sqs->quad_to_target_transform));
222 EXPECT_EQ(quad_layer_bounds, mus_sqs->quad_layer_bounds); 220 EXPECT_EQ(quad_layer_bounds, mus_sqs->quad_layer_bounds);
223 EXPECT_EQ(visible_quad_layer_rect, mus_sqs->visible_quad_layer_rect); 221 EXPECT_EQ(visible_quad_layer_rect, mus_sqs->visible_quad_layer_rect);
224 EXPECT_EQ(clip_rect, mus_sqs->clip_rect); 222 EXPECT_EQ(clip_rect, mus_sqs->clip_rect);
225 EXPECT_EQ(is_clipped, mus_sqs->is_clipped); 223 EXPECT_EQ(is_clipped, mus_sqs->is_clipped);
226 EXPECT_EQ(opacity, mus_sqs->opacity); 224 EXPECT_EQ(opacity, mus_sqs->opacity);
227 EXPECT_EQ(sorting_context_id, mus_sqs->sorting_context_id); 225 EXPECT_EQ(sorting_context_id, mus_sqs->sorting_context_id);
228 } 226 }
229 227
230 TEST(SurfaceLibTest, RenderPass) { 228 TEST(SurfaceLibTest, RenderPass) {
231 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 229 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 resource_id, gfx::Size(), premultiplied_alpha, 291 resource_id, gfx::Size(), premultiplied_alpha,
294 uv_top_left, uv_bottom_right, background_color, 292 uv_top_left, uv_bottom_right, background_color,
295 vertex_opacity, y_flipped, nearest_neighbor, 293 vertex_opacity, y_flipped, nearest_neighbor,
296 secure_output_only); 294 secure_output_only);
297 295
298 PassPtr mus_pass = Pass::From(*pass); 296 PassPtr mus_pass = Pass::From(*pass);
299 ASSERT_FALSE(mus_pass.is_null()); 297 ASSERT_FALSE(mus_pass.is_null());
300 EXPECT_EQ(6u, mus_pass->id.index); 298 EXPECT_EQ(6u, mus_pass->id.index);
301 EXPECT_EQ(output_rect, mus_pass->output_rect); 299 EXPECT_EQ(output_rect, mus_pass->output_rect);
302 EXPECT_EQ(damage_rect, mus_pass->damage_rect); 300 EXPECT_EQ(damage_rect, mus_pass->damage_rect);
303 EXPECT_TRUE(Transform::From(transform_to_root_target) 301 EXPECT_EQ(transform_to_root_target, mus_pass->transform_to_root_target);
304 .Equals(mus_pass->transform_to_root_target));
305 EXPECT_EQ(has_transparent_background, mus_pass->has_transparent_background); 302 EXPECT_EQ(has_transparent_background, mus_pass->has_transparent_background);
306 ASSERT_EQ(1u, mus_pass->shared_quad_states.size()); 303 ASSERT_EQ(1u, mus_pass->shared_quad_states.size());
307 ASSERT_EQ(3u, mus_pass->quads.size()); 304 ASSERT_EQ(3u, mus_pass->quads.size());
308 EXPECT_EQ(0u, mus_pass->quads[0]->shared_quad_state_index); 305 EXPECT_EQ(0u, mus_pass->quads[0]->shared_quad_state_index);
309 306
310 std::unique_ptr<cc::RenderPass> round_trip_pass = 307 std::unique_ptr<cc::RenderPass> round_trip_pass =
311 mus_pass.To<std::unique_ptr<cc::RenderPass>>(); 308 mus_pass.To<std::unique_ptr<cc::RenderPass>>();
312 EXPECT_EQ(pass_id, round_trip_pass->id); 309 EXPECT_EQ(pass_id, round_trip_pass->id);
313 EXPECT_EQ(output_rect, round_trip_pass->output_rect); 310 EXPECT_EQ(output_rect, round_trip_pass->output_rect);
314 EXPECT_EQ(damage_rect, round_trip_pass->damage_rect); 311 EXPECT_EQ(damage_rect, round_trip_pass->damage_rect);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 ASSERT_TRUE(mus_quad->debug_border_quad_state); 452 ASSERT_TRUE(mus_quad->debug_border_quad_state);
456 DebugBorderQuadStatePtr& mus_debug_border_state = 453 DebugBorderQuadStatePtr& mus_debug_border_state =
457 mus_quad->debug_border_quad_state; 454 mus_quad->debug_border_quad_state;
458 EXPECT_TRUE( 455 EXPECT_TRUE(
459 Color::From(arbitrary_color).Equals(mus_debug_border_state->color)); 456 Color::From(arbitrary_color).Equals(mus_debug_border_state->color));
460 EXPECT_EQ(width, mus_debug_border_state->width); 457 EXPECT_EQ(width, mus_debug_border_state->width);
461 } 458 }
462 459
463 } // namespace 460 } // namespace
464 } // namespace mojo 461 } // namespace mojo
OLDNEW
« no previous file with comments | « components/mus/public/cpp/surfaces/tests/BUILD.gn ('k') | components/mus/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698