Index: cc/caching_bitmap_canvas_layer_texture_updater.cc |
diff --git a/cc/caching_bitmap_canvas_layer_texture_updater.cc b/cc/caching_bitmap_canvas_layer_texture_updater.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..55ef4e605d141d0bd8bf9d0b2698389edba1ca39 |
--- /dev/null |
+++ b/cc/caching_bitmap_canvas_layer_texture_updater.cc |
@@ -0,0 +1,50 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+ |
+#include "caching_bitmap_canvas_layer_texture_updater.h" |
+ |
+#include "LayerPainterChromium.h" |
+#include "base/hash.h" |
+#include "skia/ext/platform_canvas.h" |
+ |
+namespace cc { |
+ |
+PassRefPtr<CachingBitmapCanvasLayerTextureUpdater> |
+CachingBitmapCanvasLayerTextureUpdater::Create( |
+ PassOwnPtr<LayerPainterChromium> painter) { |
+ return adoptRef(new CachingBitmapCanvasLayerTextureUpdater(painter)); |
+} |
+ |
+CachingBitmapCanvasLayerTextureUpdater::CachingBitmapCanvasLayerTextureUpdater( |
+ PassOwnPtr<LayerPainterChromium> painter) |
+ : BitmapCanvasLayerTextureUpdater(painter), |
+ pixels_did_change_(false), |
+ pixel_hash_(0) { |
+} |
+ |
+void CachingBitmapCanvasLayerTextureUpdater::prepareToUpdate( |
+ const IntRect& content_rect, |
+ const IntSize& tile_size, |
+ float contents_width_scale, |
+ float contents_height_scale, |
+ IntRect& resulting_opaque_rect, |
+ CCRenderingStats& stats) { |
+ BitmapCanvasLayerTextureUpdater::prepareToUpdate(content_rect, |
+ tile_size, |
+ contents_width_scale, |
+ contents_height_scale, |
+ resulting_opaque_rect, |
+ stats); |
+ |
+ const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false); |
+ SkAutoLockPixels lock(new_bitmap); |
+ uint32 new_pixel_hash = base::Hash(static_cast<const char*>(new_bitmap.getPixels()), new_bitmap.getSafeSize()); |
+ |
+ pixels_did_change_ = new_pixel_hash != pixel_hash_; |
+ pixel_hash_ = new_pixel_hash; |
+} |
+ |
+} // namespace cc |