summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_picture_layer.cc
blob: 0732b307314cf567e7ae875aee8065328abe6b65 (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
// 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.

#include "cc/test/fake_picture_layer.h"

#include "cc/test/fake_picture_layer_impl.h"

namespace cc {

FakePictureLayer::FakePictureLayer(const LayerSettings& settings,
                                   ContentLayerClient* client)
    : PictureLayer(settings, client),
      update_count_(0),
      push_properties_count_(0),
      output_surface_created_count_(0),
      always_update_resources_(false),
      disable_lcd_text_(false) {
  SetBounds(gfx::Size(1, 1));
  SetIsDrawable(true);
}

FakePictureLayer::FakePictureLayer(const LayerSettings& settings,
                                   ContentLayerClient* client,
                                   scoped_ptr<RecordingSource> source)
    : PictureLayer(settings, client, source.Pass()),
      update_count_(0),
      push_properties_count_(0),
      output_surface_created_count_(0),
      always_update_resources_(false),
      disable_lcd_text_(false) {
  SetBounds(gfx::Size(1, 1));
  SetIsDrawable(true);
}

FakePictureLayer::~FakePictureLayer() {}

scoped_ptr<LayerImpl> FakePictureLayer::CreateLayerImpl(
    LayerTreeImpl* tree_impl) {
  if (is_mask())
    return FakePictureLayerImpl::CreateMask(tree_impl, layer_id_);
  return FakePictureLayerImpl::Create(tree_impl, layer_id_);
}

bool FakePictureLayer::Update() {
  if (disable_lcd_text_)
    draw_properties().can_use_lcd_text = false;
  bool updated = PictureLayer::Update();
  update_count_++;
  return updated || always_update_resources_;
}

void FakePictureLayer::PushPropertiesTo(LayerImpl* layer) {
  PictureLayer::PushPropertiesTo(layer);
  push_properties_count_++;
}

void FakePictureLayer::OnOutputSurfaceCreated() {
  PictureLayer::OnOutputSurfaceCreated();
  output_surface_created_count_++;
}

}  // namespace cc