1// Copyright 2013 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#ifndef CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
6#define CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
7
8#include "base/memory/ref_counted.h"
9#include "cc/resources/picture_pile_impl.h"
10#include "cc/test/fake_content_layer_client.h"
11
12namespace cc {
13
14class FakePicturePileImpl : public PicturePileImpl {
15 public:
16  static scoped_refptr<FakePicturePileImpl> CreateFilledPile(
17      const gfx::Size& tile_size,
18      const gfx::Size& layer_bounds);
19  static scoped_refptr<FakePicturePileImpl> CreateEmptyPile(
20      const gfx::Size& tile_size,
21      const gfx::Size& layer_bounds);
22  static scoped_refptr<FakePicturePileImpl>
23      CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size,
24                                               const gfx::Size& layer_bounds);
25  static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile();
26
27  TilingData& tiling() { return tiling_; }
28
29  void AddRecordingAt(int x, int y);
30  void RemoveRecordingAt(int x, int y);
31  void RerecordPile();
32
33  void add_draw_rect(const gfx::RectF& rect) {
34    client_.add_draw_rect(rect, default_paint_);
35  }
36
37  void add_draw_bitmap(const SkBitmap& bitmap, const gfx::Point& point) {
38    client_.add_draw_bitmap(bitmap, point, default_paint_);
39  }
40
41  void add_draw_rect_with_paint(const gfx::RectF& rect, const SkPaint& paint) {
42    client_.add_draw_rect(rect, paint);
43  }
44
45  void add_draw_bitmap_with_paint(const SkBitmap& bitmap,
46                                  const gfx::Point& point,
47                                  const SkPaint& paint) {
48    client_.add_draw_bitmap(bitmap, point, paint);
49  }
50
51  void set_default_paint(const SkPaint& paint) {
52    default_paint_ = paint;
53  }
54
55  void set_background_color(SkColor color) {
56    background_color_ = color;
57  }
58
59  void set_contents_opaque(bool contents_opaque) {
60    contents_opaque_ = contents_opaque;
61  }
62
63  void set_contents_fill_bounds_completely(bool fills) {
64    contents_fill_bounds_completely_ = fills;
65  }
66
67  void set_clear_canvas_with_debug_color(bool clear) {
68    clear_canvas_with_debug_color_ = clear;
69  }
70
71  void set_has_text(bool has_text) { has_text_ = has_text; }
72
73  void set_is_solid_color(bool is_solid_color) {
74    is_solid_color_ = is_solid_color;
75  }
76
77 protected:
78  FakePicturePileImpl();
79  virtual ~FakePicturePileImpl();
80
81  FakeContentLayerClient client_;
82  SkPaint default_paint_;
83};
84
85}  // namespace cc
86
87#endif  // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
88