summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/resource_update.cc
blob: 5760ddf4a0dde663b3fdb6bb336d66638c1dc37d (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
// 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/resources/resource_update.h"

#include "base/logging.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"

namespace cc {

ResourceUpdate ResourceUpdate::Create(PrioritizedResource* texture,
                                      const SkBitmap* bitmap,
                                      gfx::Rect content_rect,
                                      gfx::Rect source_rect,
                                      gfx::Vector2d dest_offset) {
  CHECK(content_rect.Contains(source_rect));
  ResourceUpdate update;
  update.texture = texture;
  update.bitmap = bitmap;
  update.content_rect = content_rect;
  update.source_rect = source_rect;
  update.dest_offset = dest_offset;
  return update;
}

ResourceUpdate ResourceUpdate::CreateFromCanvas(
    PrioritizedResource* resource,
    const skia::RefPtr<SkCanvas>& canvas,
    gfx::Rect content_rect,
    gfx::Rect source_rect,
    gfx::Vector2d dest_offset) {
  CHECK(content_rect.Contains(source_rect));
  ResourceUpdate update;
  update.texture = resource;
  update.canvas = canvas;
  update.bitmap = &canvas->getDevice()->accessBitmap(false);
  update.content_rect = content_rect;
  update.source_rect = source_rect;
  update.dest_offset = dest_offset;
  return update;
}

ResourceUpdate::ResourceUpdate()
    : texture(NULL),
      bitmap(NULL) {}

ResourceUpdate::~ResourceUpdate() {}

}  // namespace cc