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

Side by Side Diff: cc/output/software_renderer_unittest.cc

Issue 2194013002: cc: Delete the Renderer base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dcheck-delegating
Patch Set: delete-renderer-base-class: rebase Created 4 years, 4 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 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
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_ = SoftwareRenderer::Create( 45 renderer_ =
46 this, &settings_, output_surface_.get(), resource_provider()); 46 SoftwareRenderer::Create(&renderer_client_, &settings_,
47 output_surface_.get(), resource_provider());
47 } 48 }
48 49
49 ResourceProvider* resource_provider() const { 50 ResourceProvider* resource_provider() const {
50 return resource_provider_.get(); 51 return resource_provider_.get();
51 } 52 }
52 53
53 SoftwareRenderer* renderer() const { return renderer_.get(); } 54 SoftwareRenderer* renderer() const { return renderer_.get(); }
54 55
55 // RendererClient implementation.
56 void SetFullRootLayerDamage() override {}
57
58 std::unique_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list, 56 std::unique_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list,
59 float device_scale_factor, 57 float device_scale_factor,
60 gfx::Rect device_viewport_rect) { 58 gfx::Rect device_viewport_rect) {
61 std::unique_ptr<SkBitmap> bitmap_result; 59 std::unique_ptr<SkBitmap> bitmap_result;
62 base::RunLoop loop; 60 base::RunLoop loop;
63 61
64 list->back()->copy_requests.push_back( 62 list->back()->copy_requests.push_back(
65 CopyOutputRequest::CreateBitmapRequest( 63 CopyOutputRequest::CreateBitmapRequest(
66 base::Bind(&SoftwareRendererTest::SaveBitmapResult, 64 base::Bind(&SoftwareRendererTest::SaveBitmapResult,
67 base::Unretained(&bitmap_result), 65 base::Unretained(&bitmap_result),
68 loop.QuitClosure()))); 66 loop.QuitClosure())));
69 67
70 renderer()->DrawFrame(list, device_scale_factor, gfx::ColorSpace(), 68 renderer()->DrawFrame(list, device_scale_factor, gfx::ColorSpace(),
71 device_viewport_rect, device_viewport_rect); 69 device_viewport_rect, device_viewport_rect);
72 loop.Run(); 70 loop.Run();
73 return bitmap_result; 71 return bitmap_result;
74 } 72 }
75 73
76 static void SaveBitmapResult(std::unique_ptr<SkBitmap>* bitmap_result, 74 static void SaveBitmapResult(std::unique_ptr<SkBitmap>* bitmap_result,
77 const base::Closure& quit_closure, 75 const base::Closure& quit_closure,
78 std::unique_ptr<CopyOutputResult> result) { 76 std::unique_ptr<CopyOutputResult> result) {
79 DCHECK(result->HasBitmap()); 77 DCHECK(result->HasBitmap());
80 *bitmap_result = result->TakeBitmap(); 78 *bitmap_result = result->TakeBitmap();
81 quit_closure.Run(); 79 quit_closure.Run();
82 } 80 }
83 81
84 protected: 82 protected:
83 class StubDirectRendererClient : public DirectRendererClient {
84 public:
85 void SetFullRootLayerDamage() override {}
86 };
87
85 RendererSettings settings_; 88 RendererSettings settings_;
86 FakeOutputSurfaceClient output_surface_client_; 89 FakeOutputSurfaceClient output_surface_client_;
87 std::unique_ptr<FakeOutputSurface> output_surface_; 90 std::unique_ptr<FakeOutputSurface> output_surface_;
88 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; 91 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
89 std::unique_ptr<ResourceProvider> resource_provider_; 92 std::unique_ptr<ResourceProvider> resource_provider_;
93 StubDirectRendererClient renderer_client_;
90 std::unique_ptr<SoftwareRenderer> renderer_; 94 std::unique_ptr<SoftwareRenderer> renderer_;
91 }; 95 };
92 96
93 TEST_F(SoftwareRendererTest, SolidColorQuad) { 97 TEST_F(SoftwareRendererTest, SolidColorQuad) {
94 gfx::Size outer_size(100, 100); 98 gfx::Size outer_size(100, 100);
95 gfx::Size inner_size(98, 98); 99 gfx::Size inner_size(98, 98);
96 gfx::Rect outer_rect(outer_size); 100 gfx::Rect outer_rect(outer_size);
97 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); 101 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size);
98 gfx::Rect visible_rect(gfx::Point(1, 2), gfx::Size(98, 97)); 102 gfx::Rect visible_rect(gfx::Point(1, 2), gfx::Size(98, 97));
99 103
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 viewport_rect, clip_rect); 451 viewport_rect, clip_rect);
448 452
449 // The damage rect should be reported to the SoftwareOutputDevice. 453 // The damage rect should be reported to the SoftwareOutputDevice.
450 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start()); 454 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start());
451 // The SkCanvas should be clipped to the damage rect. 455 // The SkCanvas should be clipped to the damage rect.
452 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end()); 456 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end());
453 } 457 }
454 458
455 } // namespace 459 } // namespace
456 } // namespace cc 460 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698