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

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

Issue 2128113002: Use a cc::Display for WebView resourceless software draws. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: displaywebview: mojom Created 4 years, 5 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
« no previous file with comments | « cc/output/software_renderer.cc ('k') | cc/surfaces/display.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
35 void InitializeRenderer( 35 void InitializeRenderer(
36 std::unique_ptr<SoftwareOutputDevice> software_output_device) { 36 std::unique_ptr<SoftwareOutputDevice> software_output_device) {
37 output_surface_ = 37 output_surface_ =
38 FakeOutputSurface::CreateSoftware(std::move(software_output_device)); 38 FakeOutputSurface::CreateSoftware(std::move(software_output_device));
39 CHECK(output_surface_->BindToClient(&output_surface_client_)); 39 CHECK(output_surface_->BindToClient(&output_surface_client_));
40 40
41 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 41 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
42 resource_provider_ = FakeResourceProvider::Create( 42 resource_provider_ = FakeResourceProvider::Create(
43 output_surface_.get(), shared_bitmap_manager_.get()); 43 output_surface_.get(), shared_bitmap_manager_.get());
44 renderer_ = SoftwareRenderer::Create( 44 renderer_ = SoftwareRenderer::Create(
45 this, &settings_, output_surface_.get(), resource_provider(), 45 this, &settings_, output_surface_.get(), resource_provider());
46 true /* use_image_hijack_canvas */);
47 } 46 }
48 47
49 ResourceProvider* resource_provider() const { 48 ResourceProvider* resource_provider() const {
50 return resource_provider_.get(); 49 return resource_provider_.get();
51 } 50 }
52 51
53 SoftwareRenderer* renderer() const { return renderer_.get(); } 52 SoftwareRenderer* renderer() const { return renderer_.get(); }
54 53
55 // RendererClient implementation. 54 // RendererClient implementation.
56 void SetFullRootLayerDamage() override {} 55 void SetFullRootLayerDamage() override {}
57 56
58 std::unique_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list, 57 std::unique_ptr<SkBitmap> DrawAndCopyOutput(RenderPassList* list,
59 float device_scale_factor, 58 float device_scale_factor,
60 gfx::Rect device_viewport_rect) { 59 gfx::Rect device_viewport_rect) {
61 std::unique_ptr<SkBitmap> bitmap_result; 60 std::unique_ptr<SkBitmap> bitmap_result;
62 base::RunLoop loop; 61 base::RunLoop loop;
63 62
64 list->back()->copy_requests.push_back( 63 list->back()->copy_requests.push_back(
65 CopyOutputRequest::CreateBitmapRequest( 64 CopyOutputRequest::CreateBitmapRequest(
66 base::Bind(&SoftwareRendererTest::SaveBitmapResult, 65 base::Bind(&SoftwareRendererTest::SaveBitmapResult,
67 base::Unretained(&bitmap_result), 66 base::Unretained(&bitmap_result),
68 loop.QuitClosure()))); 67 loop.QuitClosure())));
69 68
70 renderer()->DrawFrame(list, device_scale_factor, gfx::ColorSpace(), 69 renderer()->DrawFrame(list, device_scale_factor, gfx::ColorSpace(),
71 device_viewport_rect, device_viewport_rect, false); 70 device_viewport_rect, device_viewport_rect);
72 loop.Run(); 71 loop.Run();
73 return bitmap_result; 72 return bitmap_result;
74 } 73 }
75 74
76 static void SaveBitmapResult(std::unique_ptr<SkBitmap>* bitmap_result, 75 static void SaveBitmapResult(std::unique_ptr<SkBitmap>* bitmap_result,
77 const base::Closure& quit_closure, 76 const base::Closure& quit_closure,
78 std::unique_ptr<CopyOutputResult> result) { 77 std::unique_ptr<CopyOutputResult> result) {
79 DCHECK(result->HasBitmap()); 78 DCHECK(result->HasBitmap());
80 *bitmap_result = result->TakeBitmap(); 79 *bitmap_result = result->TakeBitmap();
81 quit_closure.Run(); 80 quit_closure.Run();
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 EXPECT_EQ( 390 EXPECT_EQ(
392 SK_ColorMAGENTA, 391 SK_ColorMAGENTA,
393 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); 392 output->getColor(interior_visible_rect.x(), interior_visible_rect.y()));
394 EXPECT_EQ(SK_ColorMAGENTA, 393 EXPECT_EQ(SK_ColorMAGENTA,
395 output->getColor(interior_visible_rect.right() - 1, 394 output->getColor(interior_visible_rect.right() - 1,
396 interior_visible_rect.bottom() - 1)); 395 interior_visible_rect.bottom() - 1));
397 } 396 }
398 397
399 } // namespace 398 } // namespace
400 } // namespace cc 399 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer.cc ('k') | cc/surfaces/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698