picture_layer.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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_LAYERS_PICTURE_LAYER_H_
6#define CC_LAYERS_PICTURE_LAYER_H_
7
8#include "cc/base/invalidation_region.h"
9#include "cc/debug/devtools_instrumentation.h"
10#include "cc/debug/micro_benchmark_controller.h"
11#include "cc/layers/layer.h"
12#include "cc/resources/picture_pile.h"
13#include "cc/trees/occlusion_tracker.h"
14
15namespace cc {
16
17class ContentLayerClient;
18class ResourceUpdateQueue;
19
20class CC_EXPORT PictureLayer : public Layer {
21 public:
22  static scoped_refptr<PictureLayer> Create(ContentLayerClient* client);
23
24  void ClearClient() { client_ = NULL; }
25
26  // Layer interface.
27  virtual bool DrawsContent() const OVERRIDE;
28  virtual scoped_ptr<LayerImpl> CreateLayerImpl(
29      LayerTreeImpl* tree_impl) OVERRIDE;
30  virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
31  virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
32  virtual void SetNeedsDisplayRect(const gfx::RectF& layer_rect) OVERRIDE;
33  virtual bool Update(ResourceUpdateQueue* queue,
34                      const OcclusionTracker<Layer>* occlusion) OVERRIDE;
35  virtual void SetIsMask(bool is_mask) OVERRIDE;
36  virtual bool SupportsLCDText() const OVERRIDE;
37  virtual skia::RefPtr<SkPicture> GetPicture() const OVERRIDE;
38  virtual bool IsSuitableForGpuRasterization() const OVERRIDE;
39
40  virtual void RunMicroBenchmark(MicroBenchmark* benchmark) OVERRIDE;
41
42  ContentLayerClient* client() { return client_; }
43
44  Picture::RecordingMode RecordingMode() const;
45
46  PicturePile* GetPicturePileForTesting() const { return pile_.get(); }
47
48 protected:
49  explicit PictureLayer(ContentLayerClient* client);
50  virtual ~PictureLayer();
51
52  void UpdateCanUseLCDText();
53
54 private:
55  ContentLayerClient* client_;
56  scoped_refptr<PicturePile> pile_;
57  devtools_instrumentation::
58      ScopedLayerObjectTracker instrumentation_object_tracker_;
59  // Invalidation to use the next time update is called.
60  InvalidationRegion pending_invalidation_;
61  // Invalidation from the last time update was called.
62  Region pile_invalidation_;
63  gfx::Rect last_updated_visible_content_rect_;
64  bool is_mask_;
65
66  int update_source_frame_number_;
67  bool can_use_lcd_text_last_frame_;
68
69  DISALLOW_COPY_AND_ASSIGN(PictureLayer);
70};
71
72}  // namespace cc
73
74#endif  // CC_LAYERS_PICTURE_LAYER_H_
75