Reenable NullOpenerRedirectForksProcess, as the offending patch has been reverted
[chromium-blink-merge.git] / cc / caching_bitmap_content_layer_updater.cc
blobddeef24d4d2123c8f589bbe065d093861d971818
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(content_rect,
38 tile_size,
39 contents_width_scale,
40 contents_height_scale,
41 resulting_opaque_rect,
42 stats);
44 const SkBitmap& new_bitmap = m_canvas->getDevice()->accessBitmap(false);
45 SkAutoLockPixels lock(new_bitmap);
46 DCHECK(new_bitmap.bytesPerPixel() > 0);
47 pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() ||
48 new_bitmap.height() != cached_bitmap_.height() ||
49 new_bitmap.width() != cached_bitmap_.width() ||
50 memcmp(new_bitmap.getPixels(),
51 cached_bitmap_.getPixels(),
52 new_bitmap.getSafeSize());
54 if (pixels_did_change_)
55 new_bitmap.deepCopyTo(&cached_bitmap_, new_bitmap.config());
58 bool CachingBitmapContentLayerUpdater::pixelsDidChange() const
60 return pixels_did_change_;
63 } // namespace cc