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

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

Issue 1494223003: cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some compilation issues in ui oops 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
« no previous file with comments | « cc/playback/transform_display_item.cc ('k') | cc/test/solid_color_content_layer_client.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 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(PaintableRegion(), settings);
53 SkPictureRecorder recorder; 53 SkPictureRecorder recorder;
54 skia::RefPtr<SkCanvas> canvas; 54 skia::RefPtr<SkCanvas> canvas;
55 skia::RefPtr<SkPicture> picture;
56 55
57 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 56 for (RectPaintVector::const_iterator it = draw_rects_.begin();
58 it != draw_rects_.end(); ++it) { 57 it != draw_rects_.end(); ++it) {
59 const gfx::RectF& draw_rect = it->first; 58 const gfx::RectF& draw_rect = it->first;
60 const SkPaint& paint = it->second; 59 const SkPaint& paint = it->second;
61 canvas = 60 canvas =
62 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); 61 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
63 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 62 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
64 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 63 display_list->CreateAndAppendItem<DrawingDisplayItem>(
65 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( 64 ToEnclosingRect(draw_rect),
66 ToEnclosingRect(draw_rect)); 65 skia::AdoptRef(recorder.endRecordingAsPicture()));
67 item->SetNew(std::move(picture));
68 } 66 }
69 67
70 for (ImageVector::const_iterator it = draw_images_.begin(); 68 for (ImageVector::const_iterator it = draw_images_.begin();
71 it != draw_images_.end(); ++it) { 69 it != draw_images_.end(); ++it) {
72 if (!it->transform.IsIdentity()) { 70 if (!it->transform.IsIdentity()) {
73 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>( 71 display_list->CreateAndAppendItem<TransformDisplayItem>(PaintableRegion(),
74 PaintableRegion()); 72 it->transform);
75 item->SetNew(it->transform);
76 } 73 }
77 canvas = skia::SharePtr( 74 canvas = skia::SharePtr(
78 recorder.beginRecording(it->image->width(), it->image->height())); 75 recorder.beginRecording(it->image->width(), it->image->height()));
79 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), 76 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(),
80 &it->paint); 77 &it->paint);
81 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 78 display_list->CreateAndAppendItem<DrawingDisplayItem>(
82 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( 79 PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture()));
83 PaintableRegion());
84 item->SetNew(std::move(picture));
85 if (!it->transform.IsIdentity()) { 80 if (!it->transform.IsIdentity()) {
86 display_list->CreateAndAppendItem<EndTransformDisplayItem>( 81 display_list->CreateAndAppendItem<EndTransformDisplayItem>(
87 PaintableRegion()); 82 PaintableRegion());
88 } 83 }
89 } 84 }
90 85
91 if (fill_with_nonsolid_color_) { 86 if (fill_with_nonsolid_color_) {
92 gfx::Rect draw_rect = PaintableRegion(); 87 gfx::Rect draw_rect = PaintableRegion();
93 bool red = true; 88 bool red = true;
94 while (!draw_rect.IsEmpty()) { 89 while (!draw_rect.IsEmpty()) {
95 SkPaint paint; 90 SkPaint paint;
96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); 91 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
97 canvas = 92 canvas =
98 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); 93 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect)));
99 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); 94 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint);
100 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 95 display_list->CreateAndAppendItem<DrawingDisplayItem>(
101 auto* item = 96 draw_rect, skia::AdoptRef(recorder.endRecordingAsPicture()));
102 display_list->CreateAndAppendItem<DrawingDisplayItem>(draw_rect);
103 item->SetNew(std::move(picture));
104 draw_rect.Inset(1, 1); 97 draw_rect.Inset(1, 1);
105 } 98 }
106 } 99 }
107 100
108 101
109 display_list->Finalize(); 102 display_list->Finalize();
110 return display_list; 103 return display_list;
111 } 104 }
112 105
113 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 106 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
114 107
115 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { 108 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const {
116 return reported_memory_usage_; 109 return reported_memory_usage_;
117 } 110 }
118 111
119 } // namespace cc 112 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/transform_display_item.cc ('k') | cc/test/solid_color_content_layer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698