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

Side by Side Diff: cc/test/fake_picture_pile_impl.cc

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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/test/fake_picture_pile_impl.h ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/test/fake_picture_pile_impl.h"
6
7 #include <algorithm>
8 #include <limits>
9 #include <utility>
10
11 #include "base/synchronization/waitable_event.h"
12 #include "cc/resources/picture_pile.h"
13 #include "cc/test/impl_side_painting_settings.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace cc {
17
18 FakePicturePileImpl::FakePicturePileImpl() : playback_allowed_event_(nullptr) {
19 }
20
21 FakePicturePileImpl::FakePicturePileImpl(
22 const PicturePile* other,
23 base::WaitableEvent* playback_allowed_event)
24 : PicturePileImpl(other, true),
25 playback_allowed_event_(playback_allowed_event),
26 tile_grid_size_(other->GetTileGridSizeForTesting()) {
27 }
28
29 FakePicturePileImpl::~FakePicturePileImpl() {}
30
31 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreatePile(
32 const gfx::Size& tile_size,
33 const gfx::Size& layer_bounds,
34 bool is_filled) {
35 FakePicturePile pile(ImplSidePaintingSettings().minimum_contents_scale,
36 ImplSidePaintingSettings().default_tile_grid_size);
37 pile.tiling().SetBorderTexels(0);
38 pile.tiling().SetTilingSize(layer_bounds);
39 pile.tiling().SetMaxTextureSize(tile_size);
40 pile.SetRecordedViewport(is_filled ? gfx::Rect(layer_bounds) : gfx::Rect());
41 pile.SetHasAnyRecordings(is_filled);
42 if (is_filled) {
43 for (int x = 0; x < pile.tiling().num_tiles_x(); ++x) {
44 for (int y = 0; y < pile.tiling().num_tiles_y(); ++y)
45 pile.AddRecordingAt(x, y);
46 }
47 }
48 scoped_refptr<FakePicturePileImpl> pile_impl(
49 new FakePicturePileImpl(&pile, nullptr));
50 return pile_impl;
51 }
52
53 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile(
54 const gfx::Size& tile_size,
55 const gfx::Size& layer_bounds) {
56 bool is_filled = true;
57 return CreatePile(tile_size, layer_bounds, is_filled);
58 }
59
60 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile(
61 const gfx::Size& tile_size,
62 const gfx::Size& layer_bounds) {
63 bool is_filled = false;
64 return CreatePile(tile_size, layer_bounds, is_filled);
65 }
66
67 scoped_refptr<FakePicturePileImpl>
68 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
69 const gfx::Size& tile_size,
70 const gfx::Size& layer_bounds,
71 bool is_solid_color) {
72 FakePicturePile pile(ImplSidePaintingSettings().minimum_contents_scale,
73 ImplSidePaintingSettings().default_tile_grid_size);
74 pile.tiling().SetBorderTexels(0);
75 pile.tiling().SetTilingSize(layer_bounds);
76 pile.tiling().SetMaxTextureSize(tile_size);
77 // This simulates a false positive for this flag.
78 pile.SetRecordedViewport(gfx::Rect());
79 pile.SetHasAnyRecordings(true);
80 pile.SetIsSolidColor(is_solid_color);
81 return make_scoped_refptr(new FakePicturePileImpl(&pile, nullptr));
82 }
83
84 scoped_refptr<FakePicturePileImpl>
85 FakePicturePileImpl::CreateInfiniteFilledPile() {
86 gfx::Size size(std::numeric_limits<int>::max(),
87 std::numeric_limits<int>::max());
88 FakePicturePile pile(ImplSidePaintingSettings().minimum_contents_scale, size);
89 pile.tiling().SetBorderTexels(0);
90 pile.tiling().SetTilingSize(size);
91 pile.tiling().SetMaxTextureSize(size);
92 pile.SetRecordedViewport(gfx::Rect(size));
93 pile.SetHasAnyRecordings(true);
94 pile.AddRecordingAt(0, 0);
95 scoped_refptr<FakePicturePileImpl> pile_impl(
96 new FakePicturePileImpl(&pile, nullptr));
97 return pile_impl;
98 }
99
100 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFromPile(
101 const PicturePile* other,
102 base::WaitableEvent* playback_allowed_event) {
103 return make_scoped_refptr(
104 new FakePicturePileImpl(other, playback_allowed_event));
105 }
106
107 void FakePicturePileImpl::PlaybackToCanvas(SkCanvas* canvas,
108 const gfx::Rect& canvas_rect,
109 float contents_scale) const {
110 if (playback_allowed_event_)
111 playback_allowed_event_->Wait();
112 PicturePileImpl::PlaybackToCanvas(canvas, canvas_rect, contents_scale);
113 }
114
115 bool FakePicturePileImpl::HasRecordingAt(int x, int y) const {
116 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y));
117 if (found == picture_map_.end())
118 return false;
119 return !!found->second.GetPicture();
120 }
121
122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_picture_pile_impl.h ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698