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

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: Remove ContentLayerClient* painter from UpdateAndExpandInvalidation and sync to head 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
« no previous file with comments | « cc/test/fake_picture_layer.cc ('k') | cc/test/fake_recording_source.cc » ('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 #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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 std::unique_ptr<FakeRecordingSource> recording_source( 43 std::unique_ptr<FakeRecordingSource> recording_source(
44 new FakeRecordingSource); 44 new FakeRecordingSource);
45 recording_source->SetRecordedViewport(gfx::Rect(layer_bounds)); 45 recording_source->SetRecordedViewport(gfx::Rect(layer_bounds));
46 recording_source->SetLayerBounds(layer_bounds); 46 recording_source->SetLayerBounds(layer_bounds);
47 return recording_source; 47 return recording_source;
48 } 48 }
49 49
50 // RecordingSource overrides. 50 // RecordingSource overrides.
51 scoped_refptr<RasterSource> CreateRasterSource( 51 scoped_refptr<RasterSource> CreateRasterSource(
52 bool can_use_lcd) const override; 52 bool can_use_lcd) const override;
53 bool IsSuitableForGpuRasterization() const override;
54 53
55 void SetDisplayListUsesCachedPicture(bool use_cached_picture) { 54 void SetDisplayListUsesCachedPicture(bool use_cached_picture) {
56 client_.set_display_list_use_cached_picture(use_cached_picture); 55 client_.set_display_list_use_cached_picture(use_cached_picture);
57 } 56 }
58 57
59 void SetRecordedViewport(const gfx::Rect& recorded_viewport) { 58 void SetRecordedViewport(const gfx::Rect& recorded_viewport) {
60 recorded_viewport_ = recorded_viewport; 59 recorded_viewport_ = recorded_viewport;
61 } 60 }
62 61
63 void SetLayerBounds(const gfx::Size& layer_bounds) { 62 void SetLayerBounds(const gfx::Size& layer_bounds) {
64 size_ = layer_bounds; 63 size_ = layer_bounds;
65 client_.set_bounds(layer_bounds); 64 client_.set_bounds(layer_bounds);
66 } 65 }
67 66
68 void SetClearCanvasWithDebugColor(bool clear) { 67 void SetClearCanvasWithDebugColor(bool clear) {
69 clear_canvas_with_debug_color_ = clear; 68 clear_canvas_with_debug_color_ = clear;
70 } 69 }
71 70
72 void Rerecord() { 71 void Rerecord() {
73 SetNeedsDisplayRect(recorded_viewport_); 72 SetNeedsDisplayRect(recorded_viewport_);
74 Region invalidation; 73 Region invalidation;
75 UpdateAndExpandInvalidation(&client_, &invalidation, size_, 0, 74 gfx::Rect new_recorded_viewport = client_.PaintableRegion();
76 RECORD_NORMALLY); 75 scoped_refptr<DisplayItemList> display_list =
76 client_.PaintContentsToDisplayList(
77 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
78 size_t painter_reported_memory_usage =
79 client_.GetApproximateUnsharedMemoryUsage();
80 UpdateAndExpandInvalidation(&invalidation, size_, new_recorded_viewport);
81 UpdateDisplayItemList(display_list, painter_reported_memory_usage);
77 } 82 }
78 83
79 void add_draw_rect(const gfx::Rect& rect) { 84 void add_draw_rect(const gfx::Rect& rect) {
80 client_.add_draw_rect(rect, default_paint_); 85 client_.add_draw_rect(rect, default_paint_);
81 } 86 }
82 87
83 void add_draw_rect_with_paint(const gfx::Rect& rect, const SkPaint& paint) { 88 void add_draw_rect_with_paint(const gfx::Rect& rect, const SkPaint& paint) {
84 client_.add_draw_rect(rect, paint); 89 client_.add_draw_rect(rect, paint);
85 } 90 }
86 91
(...skipping 25 matching lines...) Expand all
112 117
113 void set_reported_memory_usage(size_t reported_memory_usage) { 118 void set_reported_memory_usage(size_t reported_memory_usage) {
114 client_.set_reported_memory_usage(reported_memory_usage); 119 client_.set_reported_memory_usage(reported_memory_usage);
115 } 120 }
116 121
117 void reset_draws() { 122 void reset_draws() {
118 client_ = FakeContentLayerClient(); 123 client_ = FakeContentLayerClient();
119 client_.set_bounds(size_); 124 client_.set_bounds(size_);
120 } 125 }
121 126
122 void SetForceUnsuitableForGpuRasterization(bool flag) {
123 force_unsuitable_for_gpu_rasterization_ = flag;
124 }
125
126 void SetPlaybackAllowedEvent(base::WaitableEvent* event) { 127 void SetPlaybackAllowedEvent(base::WaitableEvent* event) {
127 playback_allowed_event_ = event; 128 playback_allowed_event_ = event;
128 } 129 }
129 130
130 DisplayItemList* display_list() const { return display_list_.get(); }
131
132 // Checks that the basic properties of the |other| match |this|. For the 131 // Checks that the basic properties of the |other| match |this|. For the
133 // DisplayItemList, it checks that the painted result matches the painted 132 // DisplayItemList, it checks that the painted result matches the painted
134 // result of |other|. 133 // result of |other|.
135 bool EqualsTo(const FakeRecordingSource& other); 134 bool EqualsTo(const FakeRecordingSource& other);
136 135
137 private: 136 private:
138 FakeContentLayerClient client_; 137 FakeContentLayerClient client_;
139 SkPaint default_paint_; 138 SkPaint default_paint_;
140 bool force_unsuitable_for_gpu_rasterization_;
141 base::WaitableEvent* playback_allowed_event_; 139 base::WaitableEvent* playback_allowed_event_;
142 }; 140 };
143 141
144 } // namespace cc 142 } // namespace cc
145 143
146 #endif // CC_TEST_FAKE_RECORDING_SOURCE_H_ 144 #endif // CC_TEST_FAKE_RECORDING_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/test/fake_picture_layer.cc ('k') | cc/test/fake_recording_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698