OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/output/software_renderer.h" | 5 #include "cc/output/software_renderer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "cc/test/render_pass_test_utils.h" | 24 #include "cc/test/render_pass_test_utils.h" |
25 #include "cc/test/test_shared_bitmap_manager.h" | 25 #include "cc/test/test_shared_bitmap_manager.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "third_party/skia/include/core/SkCanvas.h" | 28 #include "third_party/skia/include/core/SkCanvas.h" |
29 #include "ui/gfx/skia_util.h" | 29 #include "ui/gfx/skia_util.h" |
30 | 30 |
31 namespace cc { | 31 namespace cc { |
32 namespace { | 32 namespace { |
33 | 33 |
34 class SoftwareRendererTest : public testing::Test, public RendererClient { | 34 class SoftwareRendererTest : public testing::Test { |
35 public: | 35 public: |
36 void InitializeRenderer( | 36 void InitializeRenderer( |
37 std::unique_ptr<SoftwareOutputDevice> software_output_device) { | 37 std::unique_ptr<SoftwareOutputDevice> software_output_device) { |
38 output_surface_ = | 38 output_surface_ = |
39 FakeOutputSurface::CreateSoftware(std::move(software_output_device)); | 39 FakeOutputSurface::CreateSoftware(std::move(software_output_device)); |
40 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 40 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
41 | 41 |
42 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 42 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
43 resource_provider_ = FakeResourceProvider::Create( | 43 resource_provider_ = FakeResourceProvider::Create( |
44 output_surface_.get(), shared_bitmap_manager_.get()); | 44 output_surface_.get(), shared_bitmap_manager_.get()); |
45 renderer_ = base::MakeUnique<SoftwareRenderer>( | 45 renderer_ = base::MakeUnique<SoftwareRenderer>( |
46 this, &settings_, output_surface_.get(), resource_provider()); | 46 &settings_, output_surface_.get(), resource_provider()); |
47 renderer_->SetVisible(true); | 47 renderer_->SetVisible(true); |
48 } | 48 } |
49 | 49 |
50 ResourceProvider* resource_provider() const { | 50 ResourceProvider* resource_provider() const { |
51 return resource_provider_.get(); | 51 return resource_provider_.get(); |
52 } | 52 } |
53 | 53 |
54 SoftwareRenderer* renderer() const { return renderer_.get(); } | 54 SoftwareRenderer* renderer() const { return renderer_.get(); } |
55 | 55 |
56 // RendererClient implementation. | |
57 void SetFullRootLayerDamage() override {} | |
58 | |
59 std::unique_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list, | 56 std::unique_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list, |
60 float device_scale_factor, | 57 float device_scale_factor, |
61 gfx::Rect device_viewport_rect) { | 58 gfx::Rect device_viewport_rect) { |
62 std::unique_ptr<SkBitmap> bitmap_result; | 59 std::unique_ptr<SkBitmap> bitmap_result; |
63 base::RunLoop loop; | 60 base::RunLoop loop; |
64 | 61 |
65 list->back()->copy_requests.push_back( | 62 list->back()->copy_requests.push_back( |
66 CopyOutputRequest::CreateBitmapRequest( | 63 CopyOutputRequest::CreateBitmapRequest( |
67 base::Bind(&SoftwareRendererTest::SaveBitmapResult, | 64 base::Bind(&SoftwareRendererTest::SaveBitmapResult, |
68 base::Unretained(&bitmap_result), | 65 base::Unretained(&bitmap_result), |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 viewport_rect, clip_rect); | 448 viewport_rect, clip_rect); |
452 | 449 |
453 // The damage rect should be reported to the SoftwareOutputDevice. | 450 // The damage rect should be reported to the SoftwareOutputDevice. |
454 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start()); | 451 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start()); |
455 // The SkCanvas should be clipped to the damage rect. | 452 // The SkCanvas should be clipped to the damage rect. |
456 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end()); | 453 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end()); |
457 } | 454 } |
458 | 455 |
459 } // namespace | 456 } // namespace |
460 } // namespace cc | 457 } // namespace cc |
OLD | NEW |