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

Side by Side Diff: cc/test/fake_recording_source.h

Issue 2141233002: cc: Clean up RecordingSource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move types to the beginning of the access block 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 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 #ifndef CC_TEST_FAKE_RECORDING_SOURCE_H_ 5 #ifndef CC_TEST_FAKE_RECORDING_SOURCE_H_
6 #define CC_TEST_FAKE_RECORDING_SOURCE_H_ 6 #define CC_TEST_FAKE_RECORDING_SOURCE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "cc/base/region.h" 10 #include "cc/base/region.h"
(...skipping 11 matching lines...) Expand all
22 22
23 // This class provides method for test to add bitmap and draw rect to content 23 // This class provides method for test to add bitmap and draw rect to content
24 // layer client. This class also provides function to rerecord to generate a new 24 // layer client. This class also provides function to rerecord to generate a new
25 // display list. 25 // display list.
26 class FakeRecordingSource : public RecordingSource { 26 class FakeRecordingSource : public RecordingSource {
27 public: 27 public:
28 FakeRecordingSource(); 28 FakeRecordingSource();
29 ~FakeRecordingSource() override {} 29 ~FakeRecordingSource() override {}
30 30
31 static std::unique_ptr<FakeRecordingSource> CreateRecordingSource( 31 static std::unique_ptr<FakeRecordingSource> CreateRecordingSource(
32 const gfx::Rect& recorded_viewport,
33 const gfx::Size& layer_bounds) { 32 const gfx::Size& layer_bounds) {
34 std::unique_ptr<FakeRecordingSource> recording_source( 33 std::unique_ptr<FakeRecordingSource> recording_source(
35 new FakeRecordingSource); 34 new FakeRecordingSource);
36 recording_source->SetRecordedViewport(recorded_viewport);
37 recording_source->SetLayerBounds(layer_bounds); 35 recording_source->SetLayerBounds(layer_bounds);
38 return recording_source; 36 return recording_source;
39 } 37 }
40 38
41 static std::unique_ptr<FakeRecordingSource> CreateFilledRecordingSource( 39 static std::unique_ptr<FakeRecordingSource> CreateFilledRecordingSource(
42 const gfx::Size& layer_bounds) { 40 const gfx::Size& layer_bounds) {
43 std::unique_ptr<FakeRecordingSource> recording_source( 41 std::unique_ptr<FakeRecordingSource> recording_source(
44 new FakeRecordingSource); 42 new FakeRecordingSource);
45 recording_source->SetRecordedViewport(gfx::Rect(layer_bounds));
46 recording_source->SetLayerBounds(layer_bounds); 43 recording_source->SetLayerBounds(layer_bounds);
47 return recording_source; 44 return recording_source;
48 } 45 }
49 46
50 // RecordingSource overrides. 47 // RecordingSource overrides.
51 scoped_refptr<RasterSource> CreateRasterSource( 48 scoped_refptr<RasterSource> CreateRasterSource(
52 bool can_use_lcd) const override; 49 bool can_use_lcd) const override;
53 bool IsSuitableForGpuRasterization() const override;
54 50
55 void SetDisplayListUsesCachedPicture(bool use_cached_picture) { 51 void SetDisplayListUsesCachedPicture(bool use_cached_picture) {
56 client_.set_display_list_use_cached_picture(use_cached_picture); 52 client_.set_display_list_use_cached_picture(use_cached_picture);
57 } 53 }
58 54
59 void SetRecordedViewport(const gfx::Rect& recorded_viewport) {
60 recorded_viewport_ = recorded_viewport;
61 }
62
63 void SetLayerBounds(const gfx::Size& layer_bounds) { 55 void SetLayerBounds(const gfx::Size& layer_bounds) {
64 size_ = layer_bounds; 56 size_ = layer_bounds;
65 client_.set_bounds(layer_bounds); 57 client_.set_bounds(layer_bounds);
66 } 58 }
67 59
68 void SetClearCanvasWithDebugColor(bool clear) { 60 void SetClearCanvasWithDebugColor(bool clear) {
69 clear_canvas_with_debug_color_ = clear; 61 clear_canvas_with_debug_color_ = clear;
70 } 62 }
71 63
72 void Rerecord() { 64 void Rerecord(const gfx::Rect& recorded_viewport) {
73 SetNeedsDisplayRect(recorded_viewport_); 65 SetNeedsDisplayRect(recorded_viewport);
74 Region invalidation; 66 Region invalidation;
75 UpdateAndExpandInvalidation(&client_, &invalidation, size_, 0, 67 gfx::Rect new_recorded_viewport = client_.PaintableRegion();
76 RECORD_NORMALLY); 68 scoped_refptr<DisplayItemList> display_list =
69 client_.PaintContentsToDisplayList(
70 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
71 size_t painter_reported_memory_usage =
72 client_.GetApproximateUnsharedMemoryUsage();
73 UpdateAndExpandInvalidation(&client_, &invalidation, size_,
74 new_recorded_viewport, display_list,
75 painter_reported_memory_usage);
77 } 76 }
78 77
79 void add_draw_rect(const gfx::Rect& rect) { 78 void add_draw_rect(const gfx::Rect& rect) {
80 client_.add_draw_rect(rect, default_paint_); 79 client_.add_draw_rect(rect, default_paint_);
81 } 80 }
82 81
83 void add_draw_rect_with_paint(const gfx::Rect& rect, const SkPaint& paint) { 82 void add_draw_rect_with_paint(const gfx::Rect& rect, const SkPaint& paint) {
84 client_.add_draw_rect(rect, paint); 83 client_.add_draw_rect(rect, paint);
85 } 84 }
86 85
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 119 }
121 120
122 void SetForceUnsuitableForGpuRasterization(bool flag) { 121 void SetForceUnsuitableForGpuRasterization(bool flag) {
123 force_unsuitable_for_gpu_rasterization_ = flag; 122 force_unsuitable_for_gpu_rasterization_ = flag;
124 } 123 }
125 124
126 void SetPlaybackAllowedEvent(base::WaitableEvent* event) { 125 void SetPlaybackAllowedEvent(base::WaitableEvent* event) {
127 playback_allowed_event_ = event; 126 playback_allowed_event_ = event;
128 } 127 }
129 128
130 DisplayItemList* display_list() const { return display_list_.get(); }
131
132 // Checks that the basic properties of the |other| match |this|. For the 129 // Checks that the basic properties of the |other| match |this|. For the
133 // DisplayItemList, it checks that the painted result matches the painted 130 // DisplayItemList, it checks that the painted result matches the painted
134 // result of |other|. 131 // result of |other|.
135 bool EqualsTo(const FakeRecordingSource& other); 132 bool EqualsTo(const FakeRecordingSource& other);
136 133
137 private: 134 private:
138 FakeContentLayerClient client_; 135 FakeContentLayerClient client_;
139 SkPaint default_paint_; 136 SkPaint default_paint_;
140 bool force_unsuitable_for_gpu_rasterization_; 137 bool force_unsuitable_for_gpu_rasterization_;
141 base::WaitableEvent* playback_allowed_event_; 138 base::WaitableEvent* playback_allowed_event_;
142 }; 139 };
143 140
144 } // namespace cc 141 } // namespace cc
145 142
146 #endif // CC_TEST_FAKE_RECORDING_SOURCE_H_ 143 #endif // CC_TEST_FAKE_RECORDING_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698