| OLD | NEW |
| 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/input/selection.h" | 6 #include "cc/input/selection.h" |
| 7 #include "cc/ipc/traits_test_service.mojom.h" | 7 #include "cc/ipc/traits_test_service.mojom.h" |
| 8 #include "cc/quads/render_pass_id.h" | 8 #include "cc/quads/render_pass_id.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/skia/include/core/SkString.h" |
| 12 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" |
| 11 | 13 |
| 12 namespace cc { | 14 namespace cc { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 18 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
| 17 public: | 19 public: |
| 18 StructTraitsTest() {} | 20 StructTraitsTest() {} |
| 19 | 21 |
| 20 protected: | 22 protected: |
| 21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { | 23 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
| 22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 24 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
| 23 } | 25 } |
| 24 | 26 |
| 25 private: | 27 private: |
| 26 // TraitsTestService: | 28 // TraitsTestService: |
| 27 void EchoBeginFrameArgs(const BeginFrameArgs& b, | 29 void EchoBeginFrameArgs(const BeginFrameArgs& b, |
| 28 const EchoBeginFrameArgsCallback& callback) override { | 30 const EchoBeginFrameArgsCallback& callback) override { |
| 29 callback.Run(b); | 31 callback.Run(b); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void EchoCompositorFrameMetadata( | 34 void EchoCompositorFrameMetadata( |
| 33 const CompositorFrameMetadata& c, | 35 const CompositorFrameMetadata& c, |
| 34 const EchoCompositorFrameMetadataCallback& callback) override { | 36 const EchoCompositorFrameMetadataCallback& callback) override { |
| 35 callback.Run(c); | 37 callback.Run(c); |
| 36 } | 38 } |
| 37 | 39 |
| 40 void EchoFilterOperation( |
| 41 const FilterOperation& f, |
| 42 const EchoFilterOperationCallback& callback) override { |
| 43 callback.Run(f); |
| 44 } |
| 45 |
| 38 void EchoRenderPassId(const RenderPassId& r, | 46 void EchoRenderPassId(const RenderPassId& r, |
| 39 const EchoRenderPassIdCallback& callback) override { | 47 const EchoRenderPassIdCallback& callback) override { |
| 40 callback.Run(r); | 48 callback.Run(r); |
| 41 } | 49 } |
| 42 | 50 |
| 43 void EchoReturnedResource( | 51 void EchoReturnedResource( |
| 44 const ReturnedResource& r, | 52 const ReturnedResource& r, |
| 45 const EchoReturnedResourceCallback& callback) override { | 53 const EchoReturnedResourceCallback& callback) override { |
| 46 callback.Run(r); | 54 callback.Run(r); |
| 47 } | 55 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 &component)); | 185 &component)); |
| 178 EXPECT_EQ(7331, component.sequence_number); | 186 EXPECT_EQ(7331, component.sequence_number); |
| 179 EXPECT_EQ(satisfies_sequences.size(), output.satisfies_sequences.size()); | 187 EXPECT_EQ(satisfies_sequences.size(), output.satisfies_sequences.size()); |
| 180 for (uint32_t i = 0; i < satisfies_sequences.size(); ++i) | 188 for (uint32_t i = 0; i < satisfies_sequences.size(); ++i) |
| 181 EXPECT_EQ(satisfies_sequences[i], output.satisfies_sequences[i]); | 189 EXPECT_EQ(satisfies_sequences[i], output.satisfies_sequences[i]); |
| 182 EXPECT_EQ(referenced_surfaces.size(), output.referenced_surfaces.size()); | 190 EXPECT_EQ(referenced_surfaces.size(), output.referenced_surfaces.size()); |
| 183 for (uint32_t i = 0; i < referenced_surfaces.size(); ++i) | 191 for (uint32_t i = 0; i < referenced_surfaces.size(); ++i) |
| 184 EXPECT_EQ(referenced_surfaces[i], output.referenced_surfaces[i]); | 192 EXPECT_EQ(referenced_surfaces[i], output.referenced_surfaces[i]); |
| 185 } | 193 } |
| 186 | 194 |
| 195 TEST_F(StructTraitsTest, FilterOperation) { |
| 196 const FilterOperation inputs[] = { |
| 197 FilterOperation::CreateBlurFilter(20), |
| 198 FilterOperation::CreateDropShadowFilter(gfx::Point(4, 4), 4.0f, |
| 199 SkColorSetARGB(255, 40, 0, 0)), |
| 200 FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make( |
| 201 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), |
| 202 SkIntToScalar(9), SK_ColorBLACK, |
| 203 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, |
| 204 nullptr))}; |
| 205 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 206 for (const auto& input : inputs) { |
| 207 FilterOperation output; |
| 208 proxy->EchoFilterOperation(input, &output); |
| 209 EXPECT_EQ(input.type(), output.type()); |
| 210 switch (input.type()) { |
| 211 case FilterOperation::GRAYSCALE: |
| 212 case FilterOperation::SEPIA: |
| 213 case FilterOperation::SATURATE: |
| 214 case FilterOperation::HUE_ROTATE: |
| 215 case FilterOperation::INVERT: |
| 216 case FilterOperation::BRIGHTNESS: |
| 217 case FilterOperation::SATURATING_BRIGHTNESS: |
| 218 case FilterOperation::CONTRAST: |
| 219 case FilterOperation::OPACITY: |
| 220 case FilterOperation::BLUR: |
| 221 EXPECT_EQ(input.amount(), output.amount()); |
| 222 break; |
| 223 case FilterOperation::DROP_SHADOW: |
| 224 EXPECT_EQ(input.amount(), output.amount()); |
| 225 EXPECT_EQ(input.drop_shadow_offset(), output.drop_shadow_offset()); |
| 226 EXPECT_EQ(input.drop_shadow_color(), output.drop_shadow_color()); |
| 227 break; |
| 228 case FilterOperation::COLOR_MATRIX: |
| 229 EXPECT_EQ(0, memcmp(input.matrix(), output.matrix(), 20)); |
| 230 break; |
| 231 case FilterOperation::ZOOM: |
| 232 EXPECT_EQ(input.amount(), output.amount()); |
| 233 EXPECT_EQ(input.zoom_inset(), output.zoom_inset()); |
| 234 break; |
| 235 case FilterOperation::REFERENCE: { |
| 236 SkString input_str; |
| 237 input.image_filter()->toString(&input_str); |
| 238 SkString output_str; |
| 239 output.image_filter()->toString(&output_str); |
| 240 EXPECT_EQ(input_str, output_str); |
| 241 break; |
| 242 } |
| 243 case FilterOperation::ALPHA_THRESHOLD: |
| 244 NOTREACHED(); |
| 245 break; |
| 246 } |
| 247 } |
| 248 } |
| 249 |
| 187 TEST_F(StructTraitsTest, RenderPassId) { | 250 TEST_F(StructTraitsTest, RenderPassId) { |
| 188 const int layer_id = 1337; | 251 const int layer_id = 1337; |
| 189 const uint32_t index = 0xdeadbeef; | 252 const uint32_t index = 0xdeadbeef; |
| 190 RenderPassId input(layer_id, index); | 253 RenderPassId input(layer_id, index); |
| 191 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 254 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 192 RenderPassId output; | 255 RenderPassId output; |
| 193 proxy->EchoRenderPassId(input, &output); | 256 proxy->EchoRenderPassId(input, &output); |
| 194 EXPECT_EQ(layer_id, output.layer_id); | 257 EXPECT_EQ(layer_id, output.layer_id); |
| 195 EXPECT_EQ(index, output.index); | 258 EXPECT_EQ(index, output.index); |
| 196 } | 259 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); | 408 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); |
| 346 EXPECT_EQ(mailbox_holder.texture_target, | 409 EXPECT_EQ(mailbox_holder.texture_target, |
| 347 output.mailbox_holder.texture_target); | 410 output.mailbox_holder.texture_target); |
| 348 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); | 411 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); |
| 349 EXPECT_EQ(is_software, output.is_software); | 412 EXPECT_EQ(is_software, output.is_software); |
| 350 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); | 413 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); |
| 351 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); | 414 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); |
| 352 } | 415 } |
| 353 | 416 |
| 354 } // namespace cc | 417 } // namespace cc |
| OLD | NEW |