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

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

Issue 1484163002: Raster display item lists via a visual rect RTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head. Created 5 years 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_content_layer_client.h" 5 #include "cc/test/fake_content_layer_client.h"
6 6
7 #include "cc/playback/clip_display_item.h" 7 #include "cc/playback/clip_display_item.h"
8 #include "cc/playback/display_item_list_settings.h" 8 #include "cc/playback/display_item_list_settings.h"
9 #include "cc/playback/drawing_display_item.h" 9 #include "cc/playback/drawing_display_item.h"
10 #include "cc/playback/transform_display_item.h" 10 #include "cc/playback/transform_display_item.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 scoped_refptr<DisplayItemList> 44 scoped_refptr<DisplayItemList>
45 FakeContentLayerClient::PaintContentsToDisplayList( 45 FakeContentLayerClient::PaintContentsToDisplayList(
46 PaintingControlSetting painting_control) { 46 PaintingControlSetting painting_control) {
47 // Cached picture is used because unit tests expect to be able to 47 // Cached picture is used because unit tests expect to be able to
48 // use GatherPixelRefs. 48 // use GatherPixelRefs.
49 DisplayItemListSettings settings; 49 DisplayItemListSettings settings;
50 settings.use_cached_picture = true; 50 settings.use_cached_picture = true;
51 scoped_refptr<DisplayItemList> display_list = 51 scoped_refptr<DisplayItemList> display_list =
52 DisplayItemList::Create(PaintableRegion(), settings); 52 DisplayItemList::Create(settings);
53 SkPictureRecorder recorder; 53 SkPictureRecorder recorder;
54 skia::RefPtr<SkCanvas> canvas; 54 skia::RefPtr<SkCanvas> canvas;
55 skia::RefPtr<SkPicture> picture; 55 skia::RefPtr<SkPicture> picture;
56 56
57 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 57 for (RectPaintVector::const_iterator it = draw_rects_.begin();
58 it != draw_rects_.end(); ++it) { 58 it != draw_rects_.end(); ++it) {
59 const gfx::RectF& draw_rect = it->first; 59 const gfx::RectF& draw_rect = it->first;
60 const SkPaint& paint = it->second; 60 const SkPaint& paint = it->second;
61 canvas = 61 canvas =
62 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); 62 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
63 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 63 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
64 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 64 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
65 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( 65 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(
66 ToEnclosingRect(draw_rect)); 66 ToEnclosingRect(draw_rect));
67 item->SetNew(std::move(picture)); 67 item->SetNew(std::move(picture));
68 } 68 }
69 69
70 for (ImageVector::const_iterator it = draw_images_.begin(); 70 for (ImageVector::const_iterator it = draw_images_.begin();
71 it != draw_images_.end(); ++it) { 71 it != draw_images_.end(); ++it) {
72 if (!it->transform.IsIdentity()) { 72 if (!it->transform.IsIdentity()) {
73 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>( 73 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>(
74 PaintableRegion()); 74 PaintableRegion());
75 item->SetNew(it->transform); 75 item->SetNew(it->transform);
76 } 76 }
77 canvas = skia::SharePtr( 77 int width = it->image->width() + it->point.x();
78 recorder.beginRecording(it->image->width(), it->image->height())); 78 int height = it->image->height() + it->point.y();
79 canvas = skia::SharePtr(recorder.beginRecording(width, height));
79 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), 80 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(),
80 &it->paint); 81 &it->paint);
81 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 82 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
82 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( 83 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(
83 PaintableRegion()); 84 PaintableRegion());
84 item->SetNew(std::move(picture)); 85 item->SetNew(std::move(picture));
85 if (!it->transform.IsIdentity()) { 86 if (!it->transform.IsIdentity()) {
86 display_list->CreateAndAppendItem<EndTransformDisplayItem>( 87 display_list->CreateAndAppendItem<EndTransformDisplayItem>(
87 PaintableRegion()); 88 PaintableRegion());
88 } 89 }
(...skipping 21 matching lines...) Expand all
110 return display_list; 111 return display_list;
111 } 112 }
112 113
113 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 114 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
114 115
115 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { 116 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const {
116 return reported_memory_usage_; 117 return reported_memory_usage_;
117 } 118 }
118 119
119 } // namespace cc 120 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698