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

Side by Side Diff: cc/layers/picture_layer_unittest.cc

Issue 1811113004: Store recording invalidations in DisplayListRecordingSource, save them via Update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 years, 9 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/layers/picture_layer_impl_unittest.cc ('k') | cc/playback/display_list_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 2013 The Chromium Authors. All rights reserved. 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 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/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/layers/append_quads_data.h" 10 #include "cc/layers/append_quads_data.h"
(...skipping 28 matching lines...) Expand all
39 recording_source_viewport), 39 recording_source_viewport),
40 recording_source_viewport)); 40 recording_source_viewport));
41 } 41 }
42 42
43 FakeDisplayListRecordingSource* recording_source() { 43 FakeDisplayListRecordingSource* recording_source() {
44 return static_cast<FakeDisplayListRecordingSource*>( 44 return static_cast<FakeDisplayListRecordingSource*>(
45 recording_source_.get()); 45 recording_source_.get());
46 } 46 }
47 47
48 void set_invalidation(const Region& invalidation) { 48 void set_invalidation(const Region& invalidation) {
49 *invalidation_.region() = invalidation; 49 last_updated_invalidation_ = invalidation;
50 } 50 }
51 51
52 void set_last_updated_visible_layer_rect(const gfx::Rect& rect) { 52 void set_last_updated_visible_layer_rect(const gfx::Rect& rect) {
53 last_updated_visible_layer_rect_ = rect; 53 last_updated_visible_layer_rect_ = rect;
54 } 54 }
55 55
56 void set_update_source_frame_number(int number) { 56 void set_update_source_frame_number(int number) {
57 update_source_frame_number_ = number; 57 update_source_frame_number_ = number;
58 } 58 }
59 59
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 scoped_ptr<FakePictureLayerImpl> layer_impl = 196 scoped_ptr<FakePictureLayerImpl> layer_impl =
197 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); 197 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1);
198 198
199 layer->PushPropertiesTo(layer_impl.get()); 199 layer->PushPropertiesTo(layer_impl.get());
200 EXPECT_FALSE(layer_impl->CanHaveTilings()); 200 EXPECT_FALSE(layer_impl->CanHaveTilings());
201 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); 201 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0));
202 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); 202 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize());
203 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); 203 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings());
204 } 204 }
205 205
206 TEST(PictureLayerTest, InvalidateRasterAfterUpdate) {
207 gfx::Size layer_size(50, 50);
208 FakeContentLayerClient client;
209 client.set_bounds(layer_size);
210 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
211 layer->SetBounds(gfx::Size(50, 50));
212
213 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
214 TestTaskGraphRunner task_graph_runner;
215 scoped_ptr<FakeLayerTreeHost> host =
216 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
217 host->SetRootLayer(layer);
218 layer->SetIsDrawable(true);
219 layer->SavePaintProperties();
220
221 gfx::Rect invalidation_bounds(layer_size);
222
223 // The important two lines are the following:
224 layer->SetNeedsDisplayRect(invalidation_bounds);
225 layer->Update();
226
227 host->CommitComplete();
228 FakeImplTaskRunnerProvider impl_task_runner_provider;
229 TestSharedBitmapManager shared_bitmap_manager;
230 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
231 LayerTreeSettings layer_tree_settings = LayerTreeSettings();
232 layer_tree_settings.image_decode_tasks_enabled = true;
233 FakeLayerTreeHostImpl host_impl(layer_tree_settings,
234 &impl_task_runner_provider,
235 &shared_bitmap_manager, &task_graph_runner);
236 host_impl.SetVisible(true);
237 host_impl.InitializeRenderer(output_surface.get());
238 host_impl.CreatePendingTree();
239 host_impl.pending_tree()->SetRootLayer(
240 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1));
241 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>(
242 host_impl.pending_tree()->root_layer());
243 layer->PushPropertiesTo(layer_impl);
244
245 EXPECT_EQ(invalidation_bounds,
246 layer_impl->GetPendingInvalidation()->bounds());
247 }
248
249 TEST(PictureLayerTest, InvalidateRasterWithoutUpdate) {
250 gfx::Size layer_size(50, 50);
251 FakeContentLayerClient client;
252 client.set_bounds(layer_size);
253 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
254 layer->SetBounds(gfx::Size(50, 50));
255
256 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
257 TestTaskGraphRunner task_graph_runner;
258 scoped_ptr<FakeLayerTreeHost> host =
259 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
260 host->SetRootLayer(layer);
261 layer->SetIsDrawable(true);
262 layer->SavePaintProperties();
263
264 gfx::Rect invalidation_bounds(layer_size);
265
266 // The important line is the following (note that we do not call Update):
267 layer->SetNeedsDisplayRect(invalidation_bounds);
268
269 host->CommitComplete();
270 FakeImplTaskRunnerProvider impl_task_runner_provider;
271 TestSharedBitmapManager shared_bitmap_manager;
272 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
273 LayerTreeSettings layer_tree_settings = LayerTreeSettings();
274 layer_tree_settings.image_decode_tasks_enabled = true;
275 FakeLayerTreeHostImpl host_impl(layer_tree_settings,
276 &impl_task_runner_provider,
277 &shared_bitmap_manager, &task_graph_runner);
278 host_impl.SetVisible(true);
279 host_impl.InitializeRenderer(output_surface.get());
280 host_impl.CreatePendingTree();
281 host_impl.pending_tree()->SetRootLayer(
282 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1));
283 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>(
284 host_impl.pending_tree()->root_layer());
285 layer->PushPropertiesTo(layer_impl);
286
287 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds());
288 }
289
206 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { 290 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) {
207 gfx::Size layer_size(50, 50); 291 gfx::Size layer_size(50, 50);
208 FakeContentLayerClient client; 292 FakeContentLayerClient client;
209 client.set_bounds(layer_size); 293 client.set_bounds(layer_size);
210 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size); 294 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size);
211 client.add_draw_image(image.get(), gfx::Point(), SkPaint()); 295 client.add_draw_image(image.get(), gfx::Point(), SkPaint());
212 scoped_refptr<PictureLayer> layer = 296 scoped_refptr<PictureLayer> layer =
213 PictureLayer::Create(LayerSettings(), &client); 297 PictureLayer::Create(LayerSettings(), &client);
214 layer->SetBounds(gfx::Size(10, 10)); 298 layer->SetBounds(gfx::Size(10, 10));
215 299
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Do a main frame, record the picture layers. The frame number has changed 458 // Do a main frame, record the picture layers. The frame number has changed
375 // non-monotonically. 459 // non-monotonically.
376 layer->SetNeedsDisplay(); 460 layer->SetNeedsDisplay();
377 host2->Composite(base::TimeTicks::Now()); 461 host2->Composite(base::TimeTicks::Now());
378 EXPECT_EQ(3, layer->update_count()); 462 EXPECT_EQ(3, layer->update_count());
379 EXPECT_EQ(1, host2->source_frame_number()); 463 EXPECT_EQ(1, host2->source_frame_number());
380 } 464 }
381 465
382 } // namespace 466 } // namespace
383 } // namespace cc 467 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/playback/display_list_recording_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698