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.
5 #include "cc/resources/resource_update.h"
7 #include "base/logging.h"
8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkDevice.h"
13 ResourceUpdate
ResourceUpdate::Create(PrioritizedResource
* texture
,
14 const SkBitmap
* bitmap
,
15 gfx::Rect content_rect
,
16 gfx::Rect source_rect
,
17 gfx::Vector2d dest_offset
) {
18 CHECK(content_rect
.Contains(source_rect
));
19 ResourceUpdate update
;
20 update
.texture
= texture
;
21 update
.bitmap
= bitmap
;
22 update
.content_rect
= content_rect
;
23 update
.source_rect
= source_rect
;
24 update
.dest_offset
= dest_offset
;
28 ResourceUpdate
ResourceUpdate::CreateFromCanvas(
29 PrioritizedResource
* resource
,
30 const skia::RefPtr
<SkCanvas
>& canvas
,
31 gfx::Rect content_rect
,
32 gfx::Rect source_rect
,
33 gfx::Vector2d dest_offset
) {
34 CHECK(content_rect
.Contains(source_rect
));
35 ResourceUpdate update
;
36 update
.texture
= resource
;
37 update
.canvas
= canvas
;
38 update
.bitmap
= &canvas
->getDevice()->accessBitmap(false);
39 update
.content_rect
= content_rect
;
40 update
.source_rect
= source_rect
;
41 update
.dest_offset
= dest_offset
;
45 ResourceUpdate::ResourceUpdate()
49 ResourceUpdate::~ResourceUpdate() {}