OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/image_layer_updater.h" | 7 #include "cc/image_layer_updater.h" |
8 #include "cc/resource_update_queue.h" | 8 #include "cc/resource_update_queue.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 void ImageLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::
Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, Rendering
Stats&) | 12 void ImageLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::
Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, Rendering
Stats&) |
13 { | 13 { |
14 m_updater->updateTexture(queue, texture(), sourceRect, destOffset, partialUp
date); | 14 m_updater->updateTexture(queue, texture(), sourceRect, destOffset, partialUp
date); |
15 } | 15 } |
16 | 16 |
17 // static | 17 // static |
18 scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::create() | 18 scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::create() |
19 { | 19 { |
20 return make_scoped_refptr(new ImageLayerUpdater()); | 20 return make_scoped_refptr(new ImageLayerUpdater()); |
21 } | 21 } |
22 | 22 |
23 scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::createResource( | 23 scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::createResource( |
24 PrioritizedTextureManager* manager) | 24 PrioritizedResourceManager* manager) |
25 { | 25 { |
26 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedText
ure::create(manager))); | 26 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedReso
urce::create(manager))); |
27 } | 27 } |
28 | 28 |
29 void ImageLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedTex
ture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, boo
l partialUpdate) | 29 void ImageLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedRes
ource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bo
ol partialUpdate) |
30 { | 30 { |
31 // Source rect should never go outside the image pixels, even if this | 31 // Source rect should never go outside the image pixels, even if this |
32 // is requested because the texture extends outside the image. | 32 // is requested because the texture extends outside the image. |
33 gfx::Rect clippedSourceRect = sourceRect; | 33 gfx::Rect clippedSourceRect = sourceRect; |
34 gfx::Rect imageRect = gfx::Rect(0, 0, m_bitmap.width(), m_bitmap.height()); | 34 gfx::Rect imageRect = gfx::Rect(0, 0, m_bitmap.width(), m_bitmap.height()); |
35 clippedSourceRect.Intersect(imageRect); | 35 clippedSourceRect.Intersect(imageRect); |
36 | 36 |
37 gfx::Vector2d clippedDestOffset = destOffset + gfx::Vector2d(clippedSourceRe
ct.origin() - sourceRect.origin()); | 37 gfx::Vector2d clippedDestOffset = destOffset + gfx::Vector2d(clippedSourceRe
ct.origin() - sourceRect.origin()); |
38 | 38 |
39 ResourceUpdate upload = ResourceUpdate::Create(texture, | 39 ResourceUpdate upload = ResourceUpdate::Create(texture, |
40 &m_bitmap, | 40 &m_bitmap, |
41 imageRect, | 41 imageRect, |
42 clippedSourceRect, | 42 clippedSourceRect, |
43 clippedDestOffset); | 43 clippedDestOffset); |
44 if (partialUpdate) | 44 if (partialUpdate) |
45 queue.appendPartialUpload(upload); | 45 queue.appendPartialUpload(upload); |
46 else | 46 else |
47 queue.appendFullUpload(upload); | 47 queue.appendFullUpload(upload); |
48 } | 48 } |
49 | 49 |
50 void ImageLayerUpdater::setBitmap(const SkBitmap& bitmap) | 50 void ImageLayerUpdater::setBitmap(const SkBitmap& bitmap) |
51 { | 51 { |
52 m_bitmap = bitmap; | 52 m_bitmap = bitmap; |
53 } | 53 } |
54 | 54 |
55 } | 55 } |
OLD | NEW |