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 "caching_bitmap_content_layer_updater.h" | 5 #include "caching_bitmap_content_layer_updater.h" |
6 | 6 |
7 #include "cc/layer_painter.h" | 7 #include "cc/layer_painter.h" |
8 #include "skia/ext/platform_canvas.h" | 8 #include "skia/ext/platform_canvas.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 16 matching lines...) Expand all Loading... |
27 { | 27 { |
28 } | 28 } |
29 | 29 |
30 void CachingBitmapContentLayerUpdater::prepareToUpdate( | 30 void CachingBitmapContentLayerUpdater::prepareToUpdate( |
31 const gfx::Rect& content_rect, | 31 const gfx::Rect& content_rect, |
32 const gfx::Size& tile_size, | 32 const gfx::Size& tile_size, |
33 float contents_width_scale, | 33 float contents_width_scale, |
34 float contents_height_scale, | 34 float contents_height_scale, |
35 gfx::Rect& resulting_opaque_rect, | 35 gfx::Rect& resulting_opaque_rect, |
36 RenderingStats& stats) { | 36 RenderingStats& stats) { |
37 BitmapContentLayerUpdater::prepareToUpdate(content_rect, | 37 BitmapContentLayerUpdater::prepareToUpdate( |
38 tile_size, | 38 content_rect, |
39 contents_width_scale, | 39 tile_size, |
40 contents_height_scale, | 40 contents_width_scale, |
41 resulting_opaque_rect, | 41 contents_height_scale, |
42 stats); | 42 resulting_opaque_rect, |
| 43 stats); |
43 | 44 |
44 const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); | 45 const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); |
45 SkAutoLockPixels lock(new_bitmap); | 46 SkAutoLockPixels lock(new_bitmap); |
46 DCHECK(new_bitmap.bytesPerPixel() > 0); | 47 DCHECK(new_bitmap.bytesPerPixel() > 0); |
47 pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() || | 48 pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() || |
48 new_bitmap.height() != cached_bitmap_.height() || | 49 new_bitmap.height() != cached_bitmap_.height() || |
49 new_bitmap.width() != cached_bitmap_.width() || | 50 new_bitmap.width() != cached_bitmap_.width() || |
50 memcmp(new_bitmap.getPixels(), | 51 memcmp(new_bitmap.getPixels(), |
51 cached_bitmap_.getPixels(), | 52 cached_bitmap_.getPixels(), |
52 new_bitmap.getSafeSize()); | 53 new_bitmap.getSafeSize()); |
53 | 54 |
54 if (pixels_did_change_) | 55 if (pixels_did_change_) |
55 new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config()); | 56 new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config()); |
56 } | 57 } |
57 | 58 |
58 bool CachingBitmapContentLayerUpdater::pixelsDidChange() const | 59 bool CachingBitmapContentLayerUpdater::pixelsDidChange() const |
59 { | 60 { |
60 return pixels_did_change_; | 61 return pixels_did_change_; |
61 } | 62 } |
62 | 63 |
63 } // namespace cc | 64 } // namespace cc |
OLD | NEW |