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

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

Issue 1835843002: WIP: Fix foreignObject cullrect Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/proto/display_item.proto ('k') | cc/test/fake_display_list_raster_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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/playback/clip_display_item.h" 9 #include "cc/playback/clip_display_item.h"
10 #include "cc/playback/display_item_list_settings.h" 10 #include "cc/playback/display_item_list_settings.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 scoped_refptr<DisplayItemList> 50 scoped_refptr<DisplayItemList>
51 FakeContentLayerClient::PaintContentsToDisplayList( 51 FakeContentLayerClient::PaintContentsToDisplayList(
52 PaintingControlSetting painting_control) { 52 PaintingControlSetting painting_control) {
53 // Cached picture is used because unit tests expect to be able to 53 // Cached picture is used because unit tests expect to be able to
54 // use GatherPixelRefs. 54 // use GatherPixelRefs.
55 DisplayItemListSettings settings; 55 DisplayItemListSettings settings;
56 settings.use_cached_picture = display_list_use_cached_picture_; 56 settings.use_cached_picture = display_list_use_cached_picture_;
57 scoped_refptr<DisplayItemList> display_list = 57 scoped_refptr<DisplayItemList> display_list =
58 DisplayItemList::Create(PaintableRegion(), settings); 58 DisplayItemList::Create(settings);
59 display_list->SetRetainVisualRectsForTesting(true);
59 SkPictureRecorder recorder; 60 SkPictureRecorder recorder;
60 skia::RefPtr<SkCanvas> canvas; 61 skia::RefPtr<SkCanvas> canvas;
61 62
62 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 63 for (RectPaintVector::const_iterator it = draw_rects_.begin();
63 it != draw_rects_.end(); ++it) { 64 it != draw_rects_.end(); ++it) {
64 const gfx::RectF& draw_rect = it->first; 65 const gfx::RectF& draw_rect = it->first;
65 const SkPaint& paint = it->second; 66 const SkPaint& paint = it->second;
66 canvas = 67 canvas =
67 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); 68 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
68 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 69 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
69 display_list->CreateAndAppendItem<DrawingDisplayItem>( 70 display_list->CreateAndAppendItem<DrawingDisplayItem>(
70 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); 71 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture());
71 } 72 }
72 73
73 for (ImageVector::const_iterator it = draw_images_.begin(); 74 for (ImageVector::const_iterator it = draw_images_.begin();
74 it != draw_images_.end(); ++it) { 75 it != draw_images_.end(); ++it) {
75 if (!it->transform.IsIdentity()) { 76 if (!it->transform.IsIdentity()) {
76 display_list->CreateAndAppendItem<TransformDisplayItem>(PaintableRegion(), 77 display_list->CreateAndAppendItem<TransformDisplayItem>(PaintableRegion(),
77 it->transform); 78 it->transform);
78 } 79 }
79 canvas = skia::SharePtr( 80 int width = it->image->width() + it->point.x();
80 recorder.beginRecording(it->image->width(), it->image->height())); 81 int height = it->image->height() + it->point.y();
82 canvas = skia::SharePtr(recorder.beginRecording(width, height));
81 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), 83 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(),
82 &it->paint); 84 &it->paint);
83 display_list->CreateAndAppendItem<DrawingDisplayItem>( 85 display_list->CreateAndAppendItem<DrawingDisplayItem>(
84 PaintableRegion(), recorder.finishRecordingAsPicture()); 86 PaintableRegion(), recorder.finishRecordingAsPicture());
85 if (!it->transform.IsIdentity()) { 87 if (!it->transform.IsIdentity()) {
86 display_list->CreateAndAppendItem<EndTransformDisplayItem>( 88 display_list->CreateAndAppendItem<EndTransformDisplayItem>(
87 PaintableRegion()); 89 PaintableRegion());
88 } 90 }
89 } 91 }
90 92
91 if (fill_with_nonsolid_color_) { 93 if (fill_with_nonsolid_color_) {
92 gfx::Rect draw_rect = PaintableRegion(); 94 gfx::Rect draw_rect = PaintableRegion();
93 bool red = true; 95 bool red = true;
94 while (!draw_rect.IsEmpty()) { 96 while (!draw_rect.IsEmpty()) {
95 SkPaint paint; 97 SkPaint paint;
96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); 98 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
97 canvas = 99 canvas =
98 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); 100 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect)));
99 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); 101 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint);
100 display_list->CreateAndAppendItem<DrawingDisplayItem>( 102 display_list->CreateAndAppendItem<DrawingDisplayItem>(
101 draw_rect, recorder.finishRecordingAsPicture()); 103 draw_rect, recorder.finishRecordingAsPicture());
102 draw_rect.Inset(1, 1); 104 draw_rect.Inset(1, 1);
103 } 105 }
104 } 106 }
105 107
106
107 display_list->Finalize(); 108 display_list->Finalize();
108 return display_list; 109 return display_list;
109 } 110 }
110 111
111 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 112 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
112 113
113 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { 114 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const {
114 return reported_memory_usage_; 115 return reported_memory_usage_;
115 } 116 }
116 117
117 } // namespace cc 118 } // namespace cc
OLDNEW
« no previous file with comments | « cc/proto/display_item.proto ('k') | cc/test/fake_display_list_raster_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698