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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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/test/fake_content_layer_client.h ('k') | cc/test/fake_layer_tree_host_impl.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/resources/clip_display_item.h"
8 #include "cc/resources/drawing_display_item.h"
7 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPictureRecorder.h"
8 #include "ui/gfx/skia_util.h" 11 #include "ui/gfx/skia_util.h"
9 12
10 namespace cc { 13 namespace cc {
11 14
12 FakeContentLayerClient::FakeContentLayerClient() 15 FakeContentLayerClient::FakeContentLayerClient()
13 : fill_with_nonsolid_color_(false), last_canvas_(NULL) { 16 : fill_with_nonsolid_color_(false), last_canvas_(NULL) {
14 } 17 }
15 18
16 FakeContentLayerClient::~FakeContentLayerClient() { 19 FakeContentLayerClient::~FakeContentLayerClient() {
17 } 20 }
(...skipping 27 matching lines...) Expand all
45 bool red = true; 48 bool red = true;
46 while (!draw_rect.IsEmpty()) { 49 while (!draw_rect.IsEmpty()) {
47 SkPaint paint; 50 SkPaint paint;
48 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); 51 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
49 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 52 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
50 draw_rect.Inset(1, 1); 53 draw_rect.Inset(1, 1);
51 } 54 }
52 } 55 }
53 } 56 }
54 57
58 scoped_refptr<DisplayItemList>
59 FakeContentLayerClient::PaintContentsToDisplayList(
60 const gfx::Rect& clip,
61 GraphicsContextStatus gc_status) {
62 SkPictureRecorder recorder;
63 skia::RefPtr<SkCanvas> canvas;
64 skia::RefPtr<SkPicture> picture;
65 scoped_refptr<DisplayItemList> list = DisplayItemList::Create();
66 list->AppendItem(ClipDisplayItem::Create(clip, std::vector<SkRRect>()));
67
68 for (RectPaintVector::const_iterator it = draw_rects_.begin();
69 it != draw_rects_.end(); ++it) {
70 const gfx::RectF& draw_rect = it->first;
71 const SkPaint& paint = it->second;
72 canvas = skia::SharePtr(
73 recorder.beginRecording(draw_rect.width(), draw_rect.height()));
74 canvas->drawRectCoords(0.f, 0.f, draw_rect.width(), draw_rect.height(),
75 paint);
76 picture = skia::AdoptRef(recorder.endRecording());
77 list->AppendItem(DrawingDisplayItem::Create(
78 picture, gfx::PointF(draw_rect.x(), draw_rect.y())));
79 }
80
81 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
82 it != draw_bitmaps_.end(); ++it) {
83 canvas = skia::SharePtr(
84 recorder.beginRecording(it->bitmap.width(), it->bitmap.height()));
85 canvas->drawBitmap(it->bitmap, 0.f, 0.f, &it->paint);
86 picture = skia::AdoptRef(recorder.endRecording());
87 list->AppendItem(DrawingDisplayItem::Create(
88 picture, gfx::PointF(it->point.x(), it->point.y())));
89 }
90
91 if (fill_with_nonsolid_color_) {
92 gfx::RectF draw_rect = clip;
93 bool red = true;
94 while (!draw_rect.IsEmpty()) {
95 SkPaint paint;
96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
97 canvas =
98 skia::SharePtr(recorder.beginRecording(clip.width(), clip.height()));
99 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
100 picture = skia::AdoptRef(recorder.endRecording());
101 list->AppendItem(DrawingDisplayItem::Create(picture, gfx::PointF()));
102 draw_rect.Inset(1, 1);
103 }
104 }
105
106 list->AppendItem(EndClipDisplayItem::Create());
107 return list;
108 }
109
55 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 110 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
56 111
57 } // namespace cc 112 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_content_layer_client.h ('k') | cc/test/fake_layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698