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 texture_needs_upload_(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 texture_needs_upload_ = new_bitmap.config() != cached_bitmap_.config() || | |
44 new_bitmap.height() != cached_bitmap_.height() || | |
jamesr
2012/10/02 23:29:49
this doesn't quite align
| |
45 new_bitmap.width() != cached_bitmap_.width() || | |
46 memcmp(new_bitmap.getPixels(), | |
47 cached_bitmap_.getPixels(), | |
48 new_bitmap.getSafeSize()); | |
49 } | |
50 | |
51 void CachingBitmapCanvasLayerTextureUpdater::updateTextureRect( | |
52 CCResourceProvider* resource_provider, | |
53 CCPrioritizedTexture* texture, | |
54 const IntRect& source_rect, | |
55 const IntSize& dest_offset) { | |
56 if (!texture_needs_upload_) | |
57 return; | |
58 | |
59 BitmapCanvasLayerTextureUpdater::updateTextureRect( | |
60 resource_provider, | |
61 texture, | |
62 source_rect, | |
63 dest_offset); | |
64 | |
65 const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); | |
66 SkAutoLockPixels lock(new_bitmap); | |
67 // TODO(wjmaclean): check return status here? | |
68 new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config()); | |
69 } | |
70 | |
71 } // namespace cc | |
OLD | NEW |