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

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

Issue 1812733003: Store recording invalidations in DisplayListRecordingSource, save them via Update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 27 matching lines...) Expand all
38 recording_source_viewport), 38 recording_source_viewport),
39 recording_source_viewport)); 39 recording_source_viewport));
40 } 40 }
41 41
42 FakeDisplayListRecordingSource* recording_source() { 42 FakeDisplayListRecordingSource* recording_source() {
43 return static_cast<FakeDisplayListRecordingSource*>( 43 return static_cast<FakeDisplayListRecordingSource*>(
44 recording_source_.get()); 44 recording_source_.get());
45 } 45 }
46 46
47 void set_invalidation(const Region& invalidation) { 47 void set_invalidation(const Region& invalidation) {
48 *invalidation_.region() = invalidation; 48 last_updated_invalidation_ = invalidation;
49 } 49 }
50 50
51 void set_last_updated_visible_layer_rect(const gfx::Rect& rect) { 51 void set_last_updated_visible_layer_rect(const gfx::Rect& rect) {
52 last_updated_visible_layer_rect_ = rect; 52 last_updated_visible_layer_rect_ = rect;
53 } 53 }
54 54
55 void set_update_source_frame_number(int number) { 55 void set_update_source_frame_number(int number) {
56 update_source_frame_number_ = number; 56 update_source_frame_number_ = number;
57 } 57 }
58 58
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 scoped_ptr<FakePictureLayerImpl> layer_impl = 213 scoped_ptr<FakePictureLayerImpl> layer_impl =
214 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); 214 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1);
215 215
216 layer->PushPropertiesTo(layer_impl.get()); 216 layer->PushPropertiesTo(layer_impl.get());
217 EXPECT_FALSE(layer_impl->CanHaveTilings()); 217 EXPECT_FALSE(layer_impl->CanHaveTilings());
218 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); 218 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0));
219 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); 219 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize());
220 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); 220 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings());
221 } 221 }
222 222
223 TEST(PictureLayerTest, InvalidateRasterAfterUpdate) {
224 gfx::Size layer_size(50, 50);
225 FakeContentLayerClient client;
226 client.set_bounds(layer_size);
227 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
228 layer->SetBounds(gfx::Size(50, 50));
229
230 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
231 TestTaskGraphRunner task_graph_runner;
232 scoped_ptr<FakeLayerTreeHost> host =
233 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
234 host->SetRootLayer(layer);
235 layer->SetIsDrawable(true);
236 layer->SavePaintProperties();
237
238 gfx::Rect invalidation_bounds(layer_size);
239
240 // The important two lines are the following:
241 layer->SetNeedsDisplayRect(invalidation_bounds);
242 layer->Update();
243
244 host->CommitComplete();
245 FakeImplTaskRunnerProvider impl_task_runner_provider;
246 TestSharedBitmapManager shared_bitmap_manager;
247 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
248 LayerTreeSettings layer_tree_settings = LayerTreeSettings();
249 layer_tree_settings.image_decode_tasks_enabled = true;
250 FakeLayerTreeHostImpl host_impl(layer_tree_settings,
251 &impl_task_runner_provider,
252 &shared_bitmap_manager, &task_graph_runner);
253 host_impl.SetVisible(true);
254 host_impl.InitializeRenderer(output_surface.get());
255 host_impl.CreatePendingTree();
256 host_impl.pending_tree()->SetRootLayer(
257 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1));
258 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>(
259 host_impl.pending_tree()->root_layer());
260 layer->PushPropertiesTo(layer_impl);
261
262 EXPECT_EQ(invalidation_bounds,
263 layer_impl->GetPendingInvalidation()->bounds());
264 }
265
266 TEST(PictureLayerTest, InvalidateRasterWithoutUpdate) {
267 gfx::Size layer_size(50, 50);
268 FakeContentLayerClient client;
269 client.set_bounds(layer_size);
270 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
271 layer->SetBounds(gfx::Size(50, 50));
272
273 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
274 TestTaskGraphRunner task_graph_runner;
275 scoped_ptr<FakeLayerTreeHost> host =
276 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
277 host->SetRootLayer(layer);
278 layer->SetIsDrawable(true);
279 layer->SavePaintProperties();
280
281 gfx::Rect invalidation_bounds(layer_size);
282
283 // The important line is the following (note that we do not call Update):
284 layer->SetNeedsDisplayRect(invalidation_bounds);
285
286 host->CommitComplete();
287 FakeImplTaskRunnerProvider impl_task_runner_provider;
288 TestSharedBitmapManager shared_bitmap_manager;
289 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
290 LayerTreeSettings layer_tree_settings = LayerTreeSettings();
291 layer_tree_settings.image_decode_tasks_enabled = true;
292 FakeLayerTreeHostImpl host_impl(layer_tree_settings,
293 &impl_task_runner_provider,
294 &shared_bitmap_manager, &task_graph_runner);
295 host_impl.SetVisible(true);
296 host_impl.InitializeRenderer(output_surface.get());
297 host_impl.CreatePendingTree();
298 host_impl.pending_tree()->SetRootLayer(
299 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1));
300 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>(
301 host_impl.pending_tree()->root_layer());
302 layer->PushPropertiesTo(layer_impl);
303
304 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds());
305 }
306
223 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { 307 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) {
224 gfx::Size layer_size(50, 50); 308 gfx::Size layer_size(50, 50);
225 FakeContentLayerClient client; 309 FakeContentLayerClient client;
226 client.set_bounds(layer_size); 310 client.set_bounds(layer_size);
227 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size); 311 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size);
228 client.add_draw_image(image.get(), gfx::Point(), SkPaint()); 312 client.add_draw_image(image.get(), gfx::Point(), SkPaint());
229 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); 313 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
230 layer->SetBounds(gfx::Size(10, 10)); 314 layer->SetBounds(gfx::Size(10, 10));
231 315
232 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); 316 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // Do a main frame, record the picture layers. The frame number has changed 473 // Do a main frame, record the picture layers. The frame number has changed
390 // non-monotonically. 474 // non-monotonically.
391 layer->SetNeedsDisplay(); 475 layer->SetNeedsDisplay();
392 host2->Composite(base::TimeTicks::Now()); 476 host2->Composite(base::TimeTicks::Now());
393 EXPECT_EQ(3, layer->update_count()); 477 EXPECT_EQ(3, layer->update_count());
394 EXPECT_EQ(1, host2->source_frame_number()); 478 EXPECT_EQ(1, host2->source_frame_number());
395 } 479 }
396 480
397 } // namespace 481 } // namespace
398 } // namespace cc 482 } // 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