summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/image_layer_updater.h
blob: 44e541d77bee4a0ce5a6a03d39a9e668c1ab6a5c (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
// 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_RESOURCES_IMAGE_LAYER_UPDATER_H_
#define CC_RESOURCES_IMAGE_LAYER_UPDATER_H_

#include "cc/base/cc_export.h"
#include "cc/resources/layer_updater.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace cc {

class ResourceUpdateQueue;

class CC_EXPORT ImageLayerUpdater : public LayerUpdater {
 public:
  class Resource : public LayerUpdater::Resource {
   public:
    Resource(ImageLayerUpdater* updater,
             scoped_ptr<PrioritizedResource> texture);
    virtual ~Resource();

    virtual void Update(ResourceUpdateQueue* queue,
                        gfx::Rect source_rect,
                        gfx::Vector2d dest_offset,
                        bool partial_update) OVERRIDE;

   private:
    ImageLayerUpdater* updater_;

    DISALLOW_COPY_AND_ASSIGN(Resource);
  };

  static scoped_refptr<ImageLayerUpdater> Create();

  virtual scoped_ptr<LayerUpdater::Resource> CreateResource(
      PrioritizedResourceManager*) OVERRIDE;

  void UpdateTexture(ResourceUpdateQueue* queue,
                     PrioritizedResource* texture,
                     gfx::Rect source_rect,
                     gfx::Vector2d dest_offset,
                     bool partial_update);

  void SetBitmap(const SkBitmap& bitmap);
  bool UsingBitmap(const SkBitmap& bitmap) const;

 private:
  ImageLayerUpdater() {}
  virtual ~ImageLayerUpdater() {}

  SkBitmap bitmap_;

  DISALLOW_COPY_AND_ASSIGN(ImageLayerUpdater);
};

}  // namespace cc

#endif  // CC_RESOURCES_IMAGE_LAYER_UPDATER_H_