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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 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_raster_source.h ('k') | cc/test/fake_recording_source.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/test/fake_raster_source.h" 5 #include "cc/test/fake_raster_source.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "cc/test/fake_recording_source.h" 10 #include "cc/test/fake_recording_source.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateInfiniteFilled() { 16 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateInfiniteFilled() {
17 gfx::Size size(std::numeric_limits<int>::max() / 10, 17 gfx::Size size(std::numeric_limits<int>::max() / 10,
18 std::numeric_limits<int>::max() / 10); 18 std::numeric_limits<int>::max() / 10);
19 return CreateFilled(size); 19 return CreateFilled(size);
20 } 20 }
21 21
22 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateFilled( 22 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateFilled(
23 const gfx::Size& size) { 23 const gfx::Size& size) {
24 auto recording_source = 24 auto recording_source =
25 FakeRecordingSource::CreateFilledRecordingSource(size); 25 FakeRecordingSource::CreateFilledRecordingSource(size);
26 26
27 SkPaint red_paint; 27 PaintFlags red_paint;
28 red_paint.setColor(SK_ColorRED); 28 red_paint.setColor(SK_ColorRED);
29 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint); 29 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint);
30 30
31 SkPaint salmon_pink_paint; 31 PaintFlags salmon_pink_paint;
32 salmon_pink_paint.setColor(SK_ColorRED); 32 salmon_pink_paint.setColor(SK_ColorRED);
33 salmon_pink_paint.setAlpha(128); 33 salmon_pink_paint.setAlpha(128);
34 recording_source->add_draw_rect_with_paint(gfx::Rect(size), 34 recording_source->add_draw_rect_with_paint(gfx::Rect(size),
35 salmon_pink_paint); 35 salmon_pink_paint);
36 36
37 recording_source->Rerecord(); 37 recording_source->Rerecord();
38 38
39 return make_scoped_refptr( 39 return make_scoped_refptr(
40 new FakeRasterSource(recording_source.get(), false)); 40 new FakeRasterSource(recording_source.get(), false));
41 } 41 }
42 42
43 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateFilledLCD( 43 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateFilledLCD(
44 const gfx::Size& size) { 44 const gfx::Size& size) {
45 auto recording_source = 45 auto recording_source =
46 FakeRecordingSource::CreateFilledRecordingSource(size); 46 FakeRecordingSource::CreateFilledRecordingSource(size);
47 47
48 SkPaint red_paint; 48 PaintFlags red_paint;
49 red_paint.setColor(SK_ColorRED); 49 red_paint.setColor(SK_ColorRED);
50 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint); 50 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint);
51 51
52 gfx::Size smaller_size(size.width() - 10, size.height() - 10); 52 gfx::Size smaller_size(size.width() - 10, size.height() - 10);
53 SkPaint green_paint; 53 PaintFlags green_paint;
54 green_paint.setColor(SK_ColorGREEN); 54 green_paint.setColor(SK_ColorGREEN);
55 recording_source->add_draw_rect_with_paint(gfx::Rect(smaller_size), 55 recording_source->add_draw_rect_with_paint(gfx::Rect(smaller_size),
56 green_paint); 56 green_paint);
57 57
58 recording_source->Rerecord(); 58 recording_source->Rerecord();
59 59
60 return make_scoped_refptr(new FakeRasterSource(recording_source.get(), true)); 60 return make_scoped_refptr(new FakeRasterSource(recording_source.get(), true));
61 } 61 }
62 62
63 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateFilledSolidColor( 63 scoped_refptr<FakeRasterSource> FakeRasterSource::CreateFilledSolidColor(
64 const gfx::Size& size) { 64 const gfx::Size& size) {
65 auto recording_source = 65 auto recording_source =
66 FakeRecordingSource::CreateFilledRecordingSource(size); 66 FakeRecordingSource::CreateFilledRecordingSource(size);
67 67
68 SkPaint red_paint; 68 PaintFlags red_paint;
69 red_paint.setColor(SK_ColorRED); 69 red_paint.setColor(SK_ColorRED);
70 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint); 70 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint);
71 recording_source->Rerecord(); 71 recording_source->Rerecord();
72 auto raster_source = 72 auto raster_source =
73 make_scoped_refptr(new FakeRasterSource(recording_source.get(), false)); 73 make_scoped_refptr(new FakeRasterSource(recording_source.get(), false));
74 if (!raster_source->IsSolidColor()) 74 if (!raster_source->IsSolidColor())
75 ADD_FAILURE() << "Not solid color!"; 75 ADD_FAILURE() << "Not solid color!";
76 return raster_source; 76 return raster_source;
77 } 77 }
78 78
79 scoped_refptr<FakeRasterSource> FakeRasterSource::CreatePartiallyFilled( 79 scoped_refptr<FakeRasterSource> FakeRasterSource::CreatePartiallyFilled(
80 const gfx::Size& size, 80 const gfx::Size& size,
81 const gfx::Rect& recorded_viewport) { 81 const gfx::Rect& recorded_viewport) {
82 DCHECK(recorded_viewport.IsEmpty() || 82 DCHECK(recorded_viewport.IsEmpty() ||
83 gfx::Rect(size).Contains(recorded_viewport)); 83 gfx::Rect(size).Contains(recorded_viewport));
84 auto recording_source = 84 auto recording_source =
85 FakeRecordingSource::CreateRecordingSource(recorded_viewport, size); 85 FakeRecordingSource::CreateRecordingSource(recorded_viewport, size);
86 86
87 SkPaint red_paint; 87 PaintFlags red_paint;
88 red_paint.setColor(SK_ColorRED); 88 red_paint.setColor(SK_ColorRED);
89 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint); 89 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint);
90 90
91 gfx::Size smaller_size(size.width() - 10, size.height() - 10); 91 gfx::Size smaller_size(size.width() - 10, size.height() - 10);
92 SkPaint green_paint; 92 PaintFlags green_paint;
93 green_paint.setColor(SK_ColorGREEN); 93 green_paint.setColor(SK_ColorGREEN);
94 recording_source->add_draw_rect_with_paint(gfx::Rect(smaller_size), 94 recording_source->add_draw_rect_with_paint(gfx::Rect(smaller_size),
95 green_paint); 95 green_paint);
96 96
97 recording_source->Rerecord(); 97 recording_source->Rerecord();
98 recording_source->SetRecordedViewport(recorded_viewport); 98 recording_source->SetRecordedViewport(recorded_viewport);
99 99
100 return make_scoped_refptr( 100 return make_scoped_refptr(
101 new FakeRasterSource(recording_source.get(), false)); 101 new FakeRasterSource(recording_source.get(), false));
102 } 102 }
(...skipping 29 matching lines...) Expand all
132 132
133 FakeRasterSource::FakeRasterSource(const RecordingSource* recording_source, 133 FakeRasterSource::FakeRasterSource(const RecordingSource* recording_source,
134 bool can_use_lcd, 134 bool can_use_lcd,
135 base::WaitableEvent* playback_allowed_event) 135 base::WaitableEvent* playback_allowed_event)
136 : RasterSource(recording_source, can_use_lcd), 136 : RasterSource(recording_source, can_use_lcd),
137 playback_allowed_event_(playback_allowed_event) {} 137 playback_allowed_event_(playback_allowed_event) {}
138 138
139 FakeRasterSource::~FakeRasterSource() {} 139 FakeRasterSource::~FakeRasterSource() {}
140 140
141 void FakeRasterSource::PlaybackToCanvas( 141 void FakeRasterSource::PlaybackToCanvas(
142 SkCanvas* canvas, 142 PaintCanvas* canvas,
143 const PlaybackSettings& settings) const { 143 const PlaybackSettings& settings) const {
144 if (playback_allowed_event_) 144 if (playback_allowed_event_)
145 playback_allowed_event_->Wait(); 145 playback_allowed_event_->Wait();
146 RasterSource::PlaybackToCanvas(canvas, settings); 146 RasterSource::PlaybackToCanvas(canvas, settings);
147 } 147 }
148 148
149 } // namespace cc 149 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_raster_source.h ('k') | cc/test/fake_recording_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698