Remove extra line from unit_tests.isolate
[chromium-blink-merge.git] / cc / BitmapCanvasLayerTextureUpdater.cpp
blob3231b7d84a9e30173e23d3f9b5cb46b06f2826ac
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.
6 #include "config.h"
8 #if USE(ACCELERATED_COMPOSITING)
10 #include "BitmapCanvasLayerTextureUpdater.h"
12 #include "LayerPainterChromium.h"
13 #include "PlatformColor.h"
14 #include "skia/ext/platform_canvas.h"
16 namespace cc {
18 BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdater* textureUpdater, scoped_ptr<CCPrioritizedTexture> texture)
19 : LayerTextureUpdater::Texture(texture.Pass())
20 , m_textureUpdater(textureUpdater)
24 BitmapCanvasLayerTextureUpdater::Texture::~Texture()
28 void BitmapCanvasLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourceProvider, const IntRect& sourceRect, const IntSize& destOffset)
30 textureUpdater()->updateTextureRect(resourceProvider, texture(), sourceRect, destOffset);
33 PassRefPtr<BitmapCanvasLayerTextureUpdater> BitmapCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter)
35 return adoptRef(new BitmapCanvasLayerTextureUpdater(painter));
38 BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
39 : CanvasLayerTextureUpdater(painter)
40 , m_opaque(false)
44 BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater()
48 PassOwnPtr<LayerTextureUpdater::Texture> BitmapCanvasLayerTextureUpdater::createTexture(CCPrioritizedTextureManager* manager)
50 return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager)));
53 LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampledTexelFormat(GC3Denum textureFormat)
55 // The component order may be bgra if we uploaded bgra pixels to rgba textures.
56 return PlatformColor::sameComponentOrder(textureFormat) ?
57 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
60 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, CCRenderingStats& stats)
62 if (m_canvasSize != contentRect.size()) {
63 m_canvasSize = contentRect.size();
64 m_canvas = adoptPtr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque));
67 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats);
70 void BitmapCanvasLayerTextureUpdater::updateTextureRect(CCResourceProvider* resourceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset)
72 const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(false);
73 bitmap.lockPixels();
75 texture->upload(resourceProvider, static_cast<const uint8_t*>(bitmap.getPixels()), contentRect(), sourceRect, destOffset);
76 bitmap.unlockPixels();
79 void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque)
81 if (opaque != m_opaque) {
82 m_canvas.clear();
83 m_canvasSize = IntSize();
85 m_opaque = opaque;
88 } // namespace cc
89 #endif // USE(ACCELERATED_COMPOSITING)