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.
5 #ifndef CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
6 #define CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
11 #include "base/compiler_specific.h"
12 #include "cc/layers/content_layer_client.h"
13 #include "third_party/skia/include/core/SkPaint.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/rect_f.h"
16 #include "ui/gfx/transform.h"
22 class FakeContentLayerClient
: public ContentLayerClient
{
25 ImageData(const SkImage
* image
,
26 const gfx::Point
& point
,
27 const SkPaint
& paint
);
28 ImageData(const SkImage
* image
,
29 const gfx::Transform
& transform
,
30 const SkPaint
& paint
);
32 skia::RefPtr
<const SkImage
> image
;
34 gfx::Transform transform
;
38 FakeContentLayerClient();
39 ~FakeContentLayerClient() override
;
41 void PaintContents(SkCanvas
* canvas
,
42 const gfx::Rect
& rect
,
43 PaintingControlSetting painting_control
) override
;
44 scoped_refptr
<DisplayItemList
> PaintContentsToDisplayList(
45 const gfx::Rect
& clip
,
46 PaintingControlSetting painting_control
) override
;
47 bool FillsBoundsCompletely() const override
;
48 size_t GetApproximateUnsharedMemoryUsage() const override
;
50 void set_fill_with_nonsolid_color(bool nonsolid
) {
51 fill_with_nonsolid_color_
= nonsolid
;
54 void add_draw_rect(const gfx::Rect
& rect
, const SkPaint
& paint
) {
55 draw_rects_
.push_back(std::make_pair(gfx::RectF(rect
), paint
));
58 void add_draw_rectf(const gfx::RectF
& rect
, const SkPaint
& paint
) {
59 draw_rects_
.push_back(std::make_pair(rect
, paint
));
62 void add_draw_image(const SkImage
* image
,
63 const gfx::Point
& point
,
64 const SkPaint
& paint
) {
65 ImageData
data(image
, point
, paint
);
66 draw_images_
.push_back(data
);
69 void add_draw_image_with_transform(const SkImage
* image
,
70 const gfx::Transform
& transform
,
71 const SkPaint
& paint
) {
72 ImageData
data(image
, transform
, paint
);
73 draw_images_
.push_back(data
);
76 SkCanvas
* last_canvas() const { return last_canvas_
; }
78 PaintingControlSetting
last_painting_control() const {
79 return last_painting_control_
;
82 void set_reported_memory_usage(size_t reported_memory_usage
) {
83 reported_memory_usage_
= reported_memory_usage
;
87 typedef std::vector
<std::pair
<gfx::RectF
, SkPaint
>> RectPaintVector
;
88 typedef std::vector
<ImageData
> ImageVector
;
90 bool fill_with_nonsolid_color_
;
91 RectPaintVector draw_rects_
;
92 ImageVector draw_images_
;
93 SkCanvas
* last_canvas_
;
94 PaintingControlSetting last_painting_control_
;
95 size_t reported_memory_usage_
;
100 #endif // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_