Disable StorageInfoProviderTest.* on Valgrind bots.
[chromium-blink-merge.git] / cc / bitmap_content_layer_updater.cc
blob5200573b1d71e488ba7569e9d29e18bcddc203c7
1 // Copyright 2011 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 "cc/bitmap_content_layer_updater.h"
7 #include "cc/layer_painter.h"
8 #include "cc/rendering_stats.h"
9 #include "cc/resource_update.h"
10 #include "cc/resource_update_queue.h"
11 #include "skia/ext/platform_canvas.h"
13 namespace cc {
15 BitmapContentLayerUpdater::Resource::Resource(BitmapContentLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture)
16 : LayerUpdater::Resource(texture.Pass())
17 , m_updater(updater)
21 BitmapContentLayerUpdater::Resource::~Resource()
25 void BitmapContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&)
27 updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate);
30 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::create(scoped_ptr<LayerPainter> painter)
32 return make_scoped_refptr(new BitmapContentLayerUpdater(painter.Pass()));
35 BitmapContentLayerUpdater::BitmapContentLayerUpdater(scoped_ptr<LayerPainter> painter)
36 : ContentLayerUpdater(painter.Pass())
37 , m_opaque(false)
41 BitmapContentLayerUpdater::~BitmapContentLayerUpdater()
45 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::createResource(PrioritizedResourceManager* manager)
47 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
50 void BitmapContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats& stats)
52 if (m_canvasSize != contentRect.size()) {
53 m_canvasSize = contentRect.size();
54 m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque));
57 stats.totalPixelsRasterized += contentRect.width() * contentRect.height();
59 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats);
62 void BitmapContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
64 ResourceUpdate upload = ResourceUpdate::Create(
65 texture,
66 &m_canvas->getDevice()->accessBitmap(false),
67 contentRect(),
68 sourceRect,
69 destOffset);
70 if (partialUpdate)
71 queue.appendPartialUpload(upload);
72 else
73 queue.appendFullUpload(upload);
76 void BitmapContentLayerUpdater::setOpaque(bool opaque)
78 if (opaque != m_opaque) {
79 m_canvas.reset();
80 m_canvasSize = gfx::Size();
82 m_opaque = opaque;
85 } // namespace cc