1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
#define CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "cc/layers/content_layer_client.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/transform.h"
namespace cc {
class FakeContentLayerClient : public ContentLayerClient {
public:
struct BitmapData {
BitmapData(const SkBitmap& bitmap,
const gfx::Point& point,
const SkPaint& paint);
BitmapData(const SkBitmap& bitmap,
const gfx::Transform& transform,
const SkPaint& paint);
~BitmapData();
SkBitmap bitmap;
gfx::Point point;
gfx::Transform transform;
SkPaint paint;
};
FakeContentLayerClient();
~FakeContentLayerClient() override;
void PaintContents(SkCanvas* canvas,
const gfx::Rect& rect,
PaintingControlSetting painting_control) override;
void PaintContentsToDisplayList(
DisplayItemList* display_list,
const gfx::Rect& clip,
PaintingControlSetting painting_control) override;
bool FillsBoundsCompletely() const override;
void set_fill_with_nonsolid_color(bool nonsolid) {
fill_with_nonsolid_color_ = nonsolid;
}
void add_draw_rect(const gfx::RectF& rect, const SkPaint& paint) {
draw_rects_.push_back(std::make_pair(rect, paint));
}
void add_draw_bitmap(const SkBitmap& bitmap,
const gfx::Point& point,
const SkPaint& paint) {
BitmapData data(bitmap, point, paint);
draw_bitmaps_.push_back(data);
}
void add_draw_bitmap_with_transform(const SkBitmap& bitmap,
const gfx::Transform& transform,
const SkPaint& paint) {
BitmapData data(bitmap, transform, paint);
draw_bitmaps_.push_back(data);
}
SkCanvas* last_canvas() const { return last_canvas_; }
PaintingControlSetting last_painting_control() const {
return last_painting_control_;
}
private:
typedef std::vector<std::pair<gfx::RectF, SkPaint>> RectPaintVector;
typedef std::vector<BitmapData> BitmapVector;
bool fill_with_nonsolid_color_;
RectPaintVector draw_rects_;
BitmapVector draw_bitmaps_;
SkCanvas* last_canvas_;
PaintingControlSetting last_painting_control_;
};
} // namespace cc
#endif // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
|