OLD | NEW |
---|---|
(Empty) | |
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 "config.h" | |
6 | |
7 #include "caching_bitmap_canvas_layer_texture_updater.h" | |
8 | |
9 #include "LayerPainterChromium.h" | |
10 #include "skia/ext/platform_canvas.h" | |
11 | |
12 namespace cc { | |
13 | |
14 PassRefPtr<CachingBitmapCanvasLayerTextureUpdater> | |
15 CachingBitmapCanvasLayerTextureUpdater::Create( | |
16 PassOwnPtr<LayerPainterChromium> painter) { | |
17 return adoptRef(new CachingBitmapCanvasLayerTextureUpdater(painter)); | |
18 } | |
19 | |
20 CachingBitmapCanvasLayerTextureUpdater::CachingBitmapCanvasLayerTextureUpdater( | |
21 PassOwnPtr<LayerPainterChromium> painter) | |
22 : BitmapCanvasLayerTextureUpdater(painter), | |
23 pixels_did_change_(false) { | |
24 } | |
25 | |
26 void CachingBitmapCanvasLayerTextureUpdater::prepareToUpdate( | |
27 const IntRect& content_rect, | |
28 const IntSize& tile_size, | |
29 float contents_width_scale, | |
30 float contents_height_scale, | |
31 IntRect& resulting_opaque_rect, | |
32 CCRenderingStats& stats) { | |
33 BitmapCanvasLayerTextureUpdater::prepareToUpdate(content_rect, | |
34 tile_size, | |
35 contents_width_scale, | |
36 contents_height_scale, | |
37 resulting_opaque_rect, | |
38 stats); | |
39 | |
40 const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); | |
41 SkAutoLockPixels lock(new_bitmap); | |
42 ASSERT(new_bitmap.bytesPerPixel() > 0); | |
43 pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() || | |
44 new_bitmap.height() != cached_bitmap_.height() || | |
45 new_bitmap.width() != cached_bitmap_.width() || | |
46 memcmp(new_bitmap.getPixels(), | |
47 cached_bitmap_.getPixels(), | |
48 new_bitmap.getSafeSize()); | |
49 | |
50 if (pixels_did_change_) | |
51 new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config()); | |
52 } | |
53 | |
54 bool CachingBitmapCanvasLayerTextureUpdater::pixelsDidChange() const | |
55 { | |
56 return pixels_did_change_; | |
57 } | |
58 | |
59 } // namespace cc | |
enne (OOO)
2012/10/03 19:31:43
} // namespace cc
wjmaclean
2012/10/03 20:14:30
Done.
| |
OLD | NEW |