| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/resource_update.h" | 5 #include "cc/resources/resource_update.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 ResourceUpdate ResourceUpdate::Create(PrioritizedResource* texture, | 13 ResourceUpdate ResourceUpdate::Create(PrioritizedResource* texture, |
| 14 const SkBitmap* bitmap, | 14 const SkBitmap* bitmap, |
| 15 gfx::Rect content_rect, | 15 gfx::Rect content_rect, |
| 16 gfx::Rect source_rect, | 16 gfx::Rect source_rect, |
| 17 gfx::Vector2d dest_offset) { | 17 gfx::Vector2d dest_offset) { |
| 18 CHECK(content_rect.Contains(source_rect)); | 18 CHECK(content_rect.Contains(source_rect)); |
| 19 ResourceUpdate update; | 19 ResourceUpdate update; |
| 20 update.texture = texture; | 20 update.texture = texture; |
| 21 update.bitmap = bitmap; | 21 update.bitmap = bitmap; |
| 22 update.content_rect = content_rect; | 22 update.content_rect = content_rect; |
| 23 update.source_rect = source_rect; | 23 update.source_rect = source_rect; |
| 24 update.dest_offset = dest_offset; | 24 update.dest_offset = dest_offset; |
| 25 return update; | 25 return update; |
| 26 } | 26 } |
| 27 | 27 |
| 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; | |
| 42 return update; | |
| 43 } | |
| 44 | |
| 45 ResourceUpdate::ResourceUpdate() | 28 ResourceUpdate::ResourceUpdate() |
| 46 : texture(NULL), | 29 : texture(NULL), |
| 47 bitmap(NULL) {} | 30 bitmap(NULL) {} |
| 48 | 31 |
| 49 ResourceUpdate::~ResourceUpdate() {} | 32 ResourceUpdate::~ResourceUpdate() {} |
| 50 | 33 |
| 51 } // namespace cc | 34 } // namespace cc |
| OLD | NEW |