In iossim, ignore harmless messages from launchd.
[chromium-blink-merge.git] / cc / caching_bitmap_content_layer_updater.cc
blob937b57d72786dcbc9238a86ca52e1f5f32db8aba
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.
5 #include "caching_bitmap_content_layer_updater.h"
7 #include "cc/layer_painter.h"
8 #include "skia/ext/platform_canvas.h"
10 namespace cc {
12 scoped_refptr<CachingBitmapContentLayerUpdater>
13 CachingBitmapContentLayerUpdater::Create(
14 scoped_ptr<LayerPainter> painter) {
15 return make_scoped_refptr(new CachingBitmapContentLayerUpdater(
16 painter.Pass()));
19 CachingBitmapContentLayerUpdater::CachingBitmapContentLayerUpdater(
20 scoped_ptr<LayerPainter> painter)
21 : BitmapContentLayerUpdater(painter.Pass()),
22 pixels_did_change_(false) {
25 CachingBitmapContentLayerUpdater::
26 ~CachingBitmapContentLayerUpdater()
30 void CachingBitmapContentLayerUpdater::prepareToUpdate(
31 const gfx::Rect& content_rect,
32 const gfx::Size& tile_size,
33 float contents_width_scale,
34 float contents_height_scale,
35 gfx::Rect& resulting_opaque_rect,
36 RenderingStats& stats) {
37 BitmapContentLayerUpdater::prepareToUpdate(
38 content_rect,
39 tile_size,
40 contents_width_scale,
41 contents_height_scale,
42 resulting_opaque_rect,
43 stats);
45 const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false);
46 SkAutoLockPixels lock(new_bitmap);
47 DCHECK(new_bitmap.bytesPerPixel() > 0);
48 pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() ||
49 new_bitmap.height() != cached_bitmap_.height() ||
50 new_bitmap.width() != cached_bitmap_.width() ||
51 memcmp(new_bitmap.getPixels(),
52 cached_bitmap_.getPixels(),
53 new_bitmap.getSafeSize());
55 if (pixels_did_change_)
56 new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config());
59 bool CachingBitmapContentLayerUpdater::pixelsDidChange() const
61 return pixels_did_change_;
64 } // namespace cc