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

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

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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/test/fake_content_layer_client.h ('k') | cc/test/fake_content_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/test/fake_content_layer_client.h"
6
7 #include "cc/resources/clip_display_item.h"
8 #include "cc/resources/drawing_display_item.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPictureRecorder.h"
11 #include "ui/gfx/skia_util.h"
12
13 namespace cc {
14
15 FakeContentLayerClient::FakeContentLayerClient()
16 : fill_with_nonsolid_color_(false), last_canvas_(NULL) {
17 }
18
19 FakeContentLayerClient::~FakeContentLayerClient() {
20 }
21
22 void FakeContentLayerClient::PaintContents(
23 SkCanvas* canvas,
24 const gfx::Rect& paint_rect,
25 PaintingControlSetting painting_control) {
26 last_canvas_ = canvas;
27 last_painting_control_ = painting_control;
28
29 canvas->clipRect(gfx::RectToSkRect(paint_rect));
30 for (RectPaintVector::const_iterator it = draw_rects_.begin();
31 it != draw_rects_.end(); ++it) {
32 const gfx::RectF& draw_rect = it->first;
33 const SkPaint& paint = it->second;
34 canvas->drawRectCoords(draw_rect.x(),
35 draw_rect.y(),
36 draw_rect.right(),
37 draw_rect.bottom(),
38 paint);
39 }
40
41 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
42 it != draw_bitmaps_.end(); ++it) {
43 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint);
44 }
45
46 if (fill_with_nonsolid_color_) {
47 gfx::RectF draw_rect = paint_rect;
48 bool red = true;
49 while (!draw_rect.IsEmpty()) {
50 SkPaint paint;
51 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
52 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
53 draw_rect.Inset(1, 1);
54 }
55 }
56 }
57
58 scoped_refptr<DisplayItemList>
59 FakeContentLayerClient::PaintContentsToDisplayList(
60 const gfx::Rect& clip,
61 PaintingControlSetting painting_control) {
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 =
73 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
74 canvas->drawRectCoords(draw_rect.x(), draw_rect.y(), draw_rect.width(),
75 draw_rect.height(), paint);
76 picture = skia::AdoptRef(recorder.endRecording());
77 list->AppendItem(DrawingDisplayItem::Create(picture));
78 }
79
80 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
81 it != draw_bitmaps_.end(); ++it) {
82 canvas = skia::SharePtr(
83 recorder.beginRecording(it->bitmap.width(), it->bitmap.height()));
84 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint);
85 picture = skia::AdoptRef(recorder.endRecording());
86 list->AppendItem(DrawingDisplayItem::Create(picture));
87 }
88
89 if (fill_with_nonsolid_color_) {
90 gfx::RectF draw_rect = clip;
91 bool red = true;
92 while (!draw_rect.IsEmpty()) {
93 SkPaint paint;
94 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
95 canvas = skia::SharePtr(
96 recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
97 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
98 picture = skia::AdoptRef(recorder.endRecording());
99 list->AppendItem(DrawingDisplayItem::Create(picture));
100 draw_rect.Inset(1, 1);
101 }
102 }
103
104 list->AppendItem(EndClipDisplayItem::Create());
105 return list;
106 }
107
108 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
109
110 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_content_layer_client.h ('k') | cc/test/fake_content_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698