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. 4 5 #include "cc/resources/resource_update.h" 6 7 #include "base/logging.h" 8 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkDevice.h" 10 11 namespace cc { 12 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; 25 return update; 26 } 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() 46 : texture(NULL), 47 bitmap(NULL) {} 48 49 ResourceUpdate::~ResourceUpdate() {} 50 51 } // namespace cc 52