• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 namespace cc {
13 
14 class FakePicturePileImpl : public PicturePileImpl {
15  public:
16   static scoped_refptr<FakePicturePileImpl> CreateFilledPile(
17       gfx::Size tile_size,
18       gfx::Size layer_bounds);
19 
20   static scoped_refptr<FakePicturePileImpl> CreateEmptyPile(
21       gfx::Size tile_size,
22       gfx::Size layer_bounds);
23 
24   static scoped_refptr<FakePicturePileImpl>
25       CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size,
26                                                const gfx::Size& layer_bounds);
27   static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile();
28 
tiling()29   TilingData& tiling() { return tiling_; }
30 
31   void AddRecordingAt(int x, int y);
32   void RemoveRecordingAt(int x, int y);
33   void RerecordPile();
34 
add_draw_rect(const gfx::RectF & rect)35   void add_draw_rect(const gfx::RectF& rect) {
36     client_.add_draw_rect(rect, default_paint_);
37   }
38 
add_draw_bitmap(const SkBitmap & bitmap,gfx::Point point)39   void add_draw_bitmap(const SkBitmap& bitmap, gfx::Point point) {
40     client_.add_draw_bitmap(bitmap, point, default_paint_);
41   }
42 
add_draw_rect_with_paint(const gfx::RectF & rect,const SkPaint & paint)43   void add_draw_rect_with_paint(const gfx::RectF& rect, const SkPaint& paint) {
44     client_.add_draw_rect(rect, paint);
45   }
46 
add_draw_bitmap_with_paint(const SkBitmap & bitmap,gfx::Point point,const SkPaint & paint)47   void add_draw_bitmap_with_paint(const SkBitmap& bitmap,
48                                   gfx::Point point,
49                                   const SkPaint& paint) {
50     client_.add_draw_bitmap(bitmap, point, paint);
51   }
52 
set_default_paint(const SkPaint & paint)53   void set_default_paint(const SkPaint& paint) {
54     default_paint_ = paint;
55   }
56 
set_background_color(SkColor color)57   void set_background_color(SkColor color) {
58     background_color_ = color;
59   }
60 
set_contents_opaque(bool contents_opaque)61   void set_contents_opaque(bool contents_opaque) {
62     contents_opaque_ = contents_opaque;
63   }
64 
set_clear_canvas_with_debug_color(bool clear)65   void set_clear_canvas_with_debug_color(bool clear) {
66     clear_canvas_with_debug_color_ = clear;
67   }
68 
69  protected:
70   FakePicturePileImpl();
71   virtual ~FakePicturePileImpl();
72 
73   FakeContentLayerClient client_;
74   SkPaint default_paint_;
75 };
76 
77 }  // namespace cc
78 
79 #endif  // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
80