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