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

Side by Side Diff: cc/ipc/struct_traits_unittest.cc

Issue 2032643002: Implement cc::SharedQuadState StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make blend_mode an int in the mojom 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "cc/ipc/traits_test_service.mojom.h" 6 #include "cc/ipc/traits_test_service.mojom.h"
7 #include "cc/quads/render_pass_id.h" 7 #include "cc/quads/render_pass_id.h"
8 #include "mojo/public/cpp/bindings/binding_set.h" 8 #include "mojo/public/cpp/bindings/binding_set.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 21 matching lines...) Expand all
32 const EchoRenderPassIdCallback& callback) override { 32 const EchoRenderPassIdCallback& callback) override {
33 callback.Run(r); 33 callback.Run(r);
34 } 34 }
35 35
36 void EchoReturnedResource( 36 void EchoReturnedResource(
37 const ReturnedResource& r, 37 const ReturnedResource& r,
38 const EchoReturnedResourceCallback& callback) override { 38 const EchoReturnedResourceCallback& callback) override {
39 callback.Run(r); 39 callback.Run(r);
40 } 40 }
41 41
42 void EchoSharedQuadState(
43 const SharedQuadState& s,
44 const EchoSharedQuadStateCallback& callback) override {
45 callback.Run(s);
46 }
47
42 void EchoSurfaceId(const SurfaceId& s, 48 void EchoSurfaceId(const SurfaceId& s,
43 const EchoSurfaceIdCallback& callback) override { 49 const EchoSurfaceIdCallback& callback) override {
44 callback.Run(s); 50 callback.Run(s);
45 } 51 }
46 52
47 void EchoTransferableResource( 53 void EchoTransferableResource(
48 const TransferableResource& t, 54 const TransferableResource& t,
49 const EchoTransferableResourceCallback& callback) override { 55 const EchoTransferableResourceCallback& callback) override {
50 callback.Run(t); 56 callback.Run(t);
51 } 57 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 const uint64_t nonce = 0xdeadbeef; 127 const uint64_t nonce = 0xdeadbeef;
122 SurfaceId input(id_namespace, local_id, nonce); 128 SurfaceId input(id_namespace, local_id, nonce);
123 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 129 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
124 SurfaceId output; 130 SurfaceId output;
125 proxy->EchoSurfaceId(input, &output); 131 proxy->EchoSurfaceId(input, &output);
126 EXPECT_EQ(id_namespace, output.id_namespace()); 132 EXPECT_EQ(id_namespace, output.id_namespace());
127 EXPECT_EQ(local_id, output.local_id()); 133 EXPECT_EQ(local_id, output.local_id());
128 EXPECT_EQ(nonce, output.nonce()); 134 EXPECT_EQ(nonce, output.nonce());
129 } 135 }
130 136
137 TEST_F(StructTraitsTest, SharedQuadState) {
138 const gfx::Transform quad_to_target_transform(1.f, 2.f, 3.f, 4.f, 5.f, 6.f,
139 7.f, 8.f, 9.f, 10.f, 11.f, 12.f,
140 13.f, 14.f, 15.f, 16.f);
141 const gfx::Size layer_bounds(1234, 5678);
142 const gfx::Rect visible_layer_rect(12, 34, 56, 78);
143 const gfx::Rect clip_rect(123, 456, 789, 101112);
144 const bool is_clipped = true;
145 const float opacity = 0.9f;
146 const SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode;
147 const int sorting_context_id = 1337;
148 SharedQuadState input_sqs;
149 input_sqs.SetAll(quad_to_target_transform, layer_bounds, visible_layer_rect,
150 clip_rect, is_clipped, opacity, blend_mode,
151 sorting_context_id);
152 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
153 SharedQuadState output_sqs;
154 proxy->EchoSharedQuadState(input_sqs, &output_sqs);
155 EXPECT_EQ(quad_to_target_transform, output_sqs.quad_to_target_transform);
156 EXPECT_EQ(layer_bounds, output_sqs.quad_layer_bounds);
157 EXPECT_EQ(visible_layer_rect, output_sqs.visible_quad_layer_rect);
158 EXPECT_EQ(clip_rect, output_sqs.clip_rect);
159 EXPECT_EQ(is_clipped, output_sqs.is_clipped);
160 EXPECT_EQ(opacity, output_sqs.opacity);
161 EXPECT_EQ(blend_mode, output_sqs.blend_mode);
162 EXPECT_EQ(sorting_context_id, output_sqs.sorting_context_id);
163 }
164
131 TEST_F(StructTraitsTest, TransferableResource) { 165 TEST_F(StructTraitsTest, TransferableResource) {
132 const uint32_t id = 1337; 166 const uint32_t id = 1337;
133 const ResourceFormat format = ALPHA_8; 167 const ResourceFormat format = ALPHA_8;
134 const uint32_t filter = 1234; 168 const uint32_t filter = 1234;
135 const gfx::Size size(1234, 5678); 169 const gfx::Size size(1234, 5678);
136 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { 170 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
137 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 171 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
138 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, 172 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
139 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; 173 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7};
140 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS; 174 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); 209 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token);
176 EXPECT_EQ(mailbox_holder.texture_target, 210 EXPECT_EQ(mailbox_holder.texture_target,
177 output.mailbox_holder.texture_target); 211 output.mailbox_holder.texture_target);
178 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); 212 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled);
179 EXPECT_EQ(is_software, output.is_software); 213 EXPECT_EQ(is_software, output.is_software);
180 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); 214 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id);
181 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); 215 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate);
182 } 216 }
183 217
184 } // namespace cc 218 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698