summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_picture_pile_impl.h
blob: a57f981f0a5fd347d464583e5e696edfbf90e872 (plain)
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
// Copyright 2013 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_PICTURE_PILE_IMPL_H_
#define CC_TEST_FAKE_PICTURE_PILE_IMPL_H_

#include "base/memory/ref_counted.h"
#include "cc/playback/picture_pile_impl.h"
#include "cc/test/fake_picture_pile.h"

namespace base {
class WaitableEvent;
}

namespace cc {

class FakePicturePileImpl : public PicturePileImpl {
 public:
  static scoped_refptr<FakePicturePileImpl> CreatePile(
      const gfx::Size& tile_size,
      const gfx::Size& layer_bounds,
      bool is_filled);

  static scoped_refptr<FakePicturePileImpl> CreateFilledPileWithDefaultTileSize(
      const gfx::Size& layer_bounds) {
    return CreateFilledPile(gfx::Size(512, 512), layer_bounds);
  }
  static scoped_refptr<FakePicturePileImpl> CreateEmptyPileWithDefaultTileSize(
      const gfx::Size& layer_bounds) {
    return CreateEmptyPile(gfx::Size(512, 512), layer_bounds);
  }
  static scoped_refptr<FakePicturePileImpl> CreateFilledPile(
      const gfx::Size& tile_size,
      const gfx::Size& layer_bounds);
  static scoped_refptr<FakePicturePileImpl> CreateEmptyPile(
      const gfx::Size& tile_size,
      const gfx::Size& layer_bounds);
  static scoped_refptr<FakePicturePileImpl>
  CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size,
                                           const gfx::Size& layer_bounds,
                                           bool is_solid_color);
  static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile();
  static scoped_refptr<FakePicturePileImpl> CreateFromPile(
      const PicturePile* other,
      base::WaitableEvent* playback_allowed_event);

  // Hi-jack the PlaybackToCanvas method to delay its completion.
  void PlaybackToCanvas(SkCanvas* canvas,
                        const gfx::Rect& canvas_bitmap_rect,
                        const gfx::Rect& canvas_playback_rect,
                        float contents_scale) const override;

  const TilingData& tiling() { return tiling_; }

  bool HasRecordingAt(int x, int y) const;
  int num_tiles_x() const { return tiling_.num_tiles_x(); }
  int num_tiles_y() const { return tiling_.num_tiles_y(); }

 protected:
  FakePicturePileImpl();
  FakePicturePileImpl(const PicturePile* other,
                      base::WaitableEvent* playback_allowed_event);
  ~FakePicturePileImpl() override;

  base::WaitableEvent* playback_allowed_event_;
  gfx::Size tile_grid_size_;
};

}  // namespace cc

#endif  // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_