summaryrefslogtreecommitdiffstats
path: root/cc/picture_pile_impl.h
blob: 5e9d65d4026cd8f28680e834016df798e61be0a3 (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
// 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.

#ifndef CC_PICTURE_PILE_IMPL_H_
#define CC_PICTURE_PILE_IMPL_H_

#include <map>

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/threading/thread.h"
#include "cc/cc_export.h"
#include "cc/picture.h"
#include "cc/picture_pile.h"
#include "cc/scoped_ptr_vector.h"
#include "ui/gfx/rect.h"

namespace cc {
struct RenderingStats;

class CC_EXPORT PicturePileImpl : public base::RefCounted<PicturePileImpl> {
public:
  static scoped_refptr<PicturePileImpl> Create();

  // Get paint-safe version of this picture for a specific thread.
  PicturePileImpl* GetCloneForDrawingOnThread(base::Thread*);

  // Clone a paint-safe version of this picture.
  scoped_refptr<PicturePileImpl> CloneForDrawing() const;

  // Raster a subrect of this PicturePileImpl into the given canvas.
  // It's only safe to call paint on a cloned version.
  // It is assumed that contentsScale has already been applied to this canvas.
  void Raster(
      SkCanvas* canvas,
      gfx::Rect content_rect,
      float contents_scale,
      RenderingStats* stats);

private:
  friend class PicturePile;

  PicturePileImpl();
  ~PicturePileImpl();

  PicturePile::Pile pile_;

  typedef std::map<base::PlatformThreadId, scoped_refptr<PicturePileImpl> >
      CloneMap;
  CloneMap clones_;

  friend class base::RefCounted<PicturePileImpl>;
  DISALLOW_COPY_AND_ASSIGN(PicturePileImpl);
};

}  // namespace cc

#endif  // CC_PICTURE_PILE_IMPL_H_