Implement android_webview url intercepting.
[chromium-blink-merge.git] / cc / bitmap_canvas_layer_texture_updater.cc
blobae1fea914bbe1073bdc9921f8a8ac64b78ce57e6
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 #include "BitmapCanvasLayerTextureUpdater.h"
10 #include "CCTextureUpdateQueue.h"
11 #include "LayerPainterChromium.h"
12 #include "PlatformColor.h"
13 #include "skia/ext/platform_canvas.h"
15 namespace cc {
17 BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdater* textureUpdater, scoped_ptr<CCPrioritizedTexture> texture)
18 : LayerTextureUpdater::Texture(texture.Pass())
19 , m_textureUpdater(textureUpdater)
23 BitmapCanvasLayerTextureUpdater::Texture::~Texture()
27 void BitmapCanvasLayerTextureUpdater::Texture::update(CCTextureUpdateQueue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, CCRenderingStats&)
29 textureUpdater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate);
32 PassRefPtr<BitmapCanvasLayerTextureUpdater> BitmapCanvasLayerTextureUpdater::create(scoped_ptr<LayerPainterChromium> painter)
34 return adoptRef(new BitmapCanvasLayerTextureUpdater(painter.Pass()));
37 BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater(scoped_ptr<LayerPainterChromium> painter)
38 : CanvasLayerTextureUpdater(painter.Pass())
39 , m_opaque(false)
43 BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater()
47 PassOwnPtr<LayerTextureUpdater::Texture> BitmapCanvasLayerTextureUpdater::createTexture(CCPrioritizedTextureManager* manager)
49 return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager)));
52 LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampledTexelFormat(GC3Denum textureFormat)
54 // The component order may be bgra if we uploaded bgra pixels to rgba textures.
55 return PlatformColor::sameComponentOrder(textureFormat) ?
56 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
59 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, CCRenderingStats& stats)
61 if (m_canvasSize != contentRect.size()) {
62 m_canvasSize = contentRect.size();
63 m_canvas = adoptPtr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque));
66 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats);
69 void BitmapCanvasLayerTextureUpdater::updateTexture(CCTextureUpdateQueue& queue, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate)
71 TextureUploader::Parameters upload = { texture, &m_canvas->getDevice()->accessBitmap(false), NULL, { contentRect(), sourceRect, destOffset } };
72 if (partialUpdate)
73 queue.appendPartialUpload(upload);
74 else
75 queue.appendFullUpload(upload);
78 void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque)
80 if (opaque != m_opaque) {
81 m_canvas.clear();
82 m_canvasSize = IntSize();
84 m_opaque = opaque;
87 } // namespace cc