1// Copyright 2011 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_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_
6#define CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_
7
8#include "cc/resources/content_layer_updater.h"
9#include "skia/ext/refptr.h"
10#include "third_party/skia/include/core/SkPicture.h"
11
12class SkCanvas;
13
14namespace cc {
15
16class LayerPainter;
17
18// This class records the content_rect into an SkPicture. Subclass provides
19// SkCanvas to DrawPicture() for tile updating based on this recorded picture.
20class SkPictureContentLayerUpdater : public ContentLayerUpdater {
21 protected:
22  SkPictureContentLayerUpdater(
23      scoped_ptr<LayerPainter> painter,
24      RenderingStatsInstrumentation* stats_instrumentation,
25      int layer_id);
26  virtual ~SkPictureContentLayerUpdater();
27
28  virtual void PrepareToUpdate(const gfx::Size& content_size,
29                               const gfx::Rect& paint_rect,
30                               const gfx::Size& tile_size,
31                               float contents_width_scale,
32                               float contents_height_scale) OVERRIDE;
33  void DrawPicture(SkCanvas* canvas);
34
35 private:
36  skia::RefPtr<SkPicture> picture_;
37
38  DISALLOW_COPY_AND_ASSIGN(SkPictureContentLayerUpdater);
39};
40
41}  // namespace cc
42
43#endif  // CC_RESOURCES_SKPICTURE_CONTENT_LAYER_UPDATER_H_
44