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.
4 
5 #ifndef CC_TEST_FAKE_PICTURE_LAYER_H_
6 #define CC_TEST_FAKE_PICTURE_LAYER_H_
7 
8 #include <stddef.h>
9 
10 #include <memory>
11 
12 #include "base/memory/ref_counted.h"
13 #include "cc/layers/picture_layer.h"
14 #include "cc/layers/recording_source.h"
15 
16 namespace cc {
17 class FakePictureLayer : public PictureLayer {
18  public:
Create(ContentLayerClient * client)19   static scoped_refptr<FakePictureLayer> Create(ContentLayerClient* client) {
20     return base::WrapRefCounted(new FakePictureLayer(client));
21   }
22 
CreateWithRecordingSource(ContentLayerClient * client,std::unique_ptr<RecordingSource> source)23   static scoped_refptr<FakePictureLayer> CreateWithRecordingSource(
24       ContentLayerClient* client,
25       std::unique_ptr<RecordingSource> source) {
26     return base::WrapRefCounted(
27         new FakePictureLayer(client, std::move(source)));
28   }
29 
30   // Layer implementation.
31   std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
32   bool Update() override;
33 
update_count()34   int update_count() const { return update_count_; }
reset_update_count()35   void reset_update_count() { update_count_ = 0; }
36 
set_always_update_resources(bool always_update_resources)37   void set_always_update_resources(bool always_update_resources) {
38     always_update_resources_ = always_update_resources;
39   }
40 
set_fixed_tile_size(gfx::Size fixed_tile_size)41   void set_fixed_tile_size(gfx::Size fixed_tile_size) {
42     fixed_tile_size_ = fixed_tile_size;
43   }
44 
45  private:
46   explicit FakePictureLayer(ContentLayerClient* client);
47   FakePictureLayer(ContentLayerClient* client,
48                    std::unique_ptr<RecordingSource> source);
49   ~FakePictureLayer() override;
50 
51   int update_count_ = 0;
52   bool always_update_resources_ = false;
53 
54   gfx::Size fixed_tile_size_;
55 };
56 
57 }  // namespace cc
58 
59 #endif  // CC_TEST_FAKE_PICTURE_LAYER_H_
60