OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/bitmap_canvas_layer_texture_updater.h" | 7 #include "cc/bitmap_canvas_layer_texture_updater.h" |
8 | 8 |
9 #include "CCTextureUpdateQueue.h" | 9 #include "CCTextureUpdateQueue.h" |
10 #include "cc/layer_painter.h" | 10 #include "cc/layer_painter.h" |
11 #include "cc/platform_color.h" | 11 #include "cc/platform_color.h" |
12 #include "skia/ext/platform_canvas.h" | 12 #include "skia/ext/platform_canvas.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdate
r* textureUpdater, scoped_ptr<CCPrioritizedTexture> texture) | 16 BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdate
r* textureUpdater, scoped_ptr<PrioritizedTexture> texture) |
17 : LayerTextureUpdater::Texture(texture.Pass()) | 17 : LayerTextureUpdater::Texture(texture.Pass()) |
18 , m_textureUpdater(textureUpdater) | 18 , m_textureUpdater(textureUpdater) |
19 { | 19 { |
20 } | 20 } |
21 | 21 |
22 BitmapCanvasLayerTextureUpdater::Texture::~Texture() | 22 BitmapCanvasLayerTextureUpdater::Texture::~Texture() |
23 { | 23 { |
24 } | 24 } |
25 | 25 |
26 void BitmapCanvasLayerTextureUpdater::Texture::update(CCTextureUpdateQueue& queu
e, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, CCR
enderingStats&) | 26 void BitmapCanvasLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue,
const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, Rende
ringStats&) |
27 { | 27 { |
28 textureUpdater()->updateTexture(queue, texture(), sourceRect, destOffset, pa
rtialUpdate); | 28 textureUpdater()->updateTexture(queue, texture(), sourceRect, destOffset, pa
rtialUpdate); |
29 } | 29 } |
30 | 30 |
31 scoped_refptr<BitmapCanvasLayerTextureUpdater> BitmapCanvasLayerTextureUpdater::
create(scoped_ptr<LayerPainterChromium> painter) | 31 scoped_refptr<BitmapCanvasLayerTextureUpdater> BitmapCanvasLayerTextureUpdater::
create(scoped_ptr<LayerPainter> painter) |
32 { | 32 { |
33 return make_scoped_refptr(new BitmapCanvasLayerTextureUpdater(painter.Pass()
)); | 33 return make_scoped_refptr(new BitmapCanvasLayerTextureUpdater(painter.Pass()
)); |
34 } | 34 } |
35 | 35 |
36 BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater(scoped_ptr<Laye
rPainterChromium> painter) | 36 BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater(scoped_ptr<Laye
rPainter> painter) |
37 : CanvasLayerTextureUpdater(painter.Pass()) | 37 : CanvasLayerTextureUpdater(painter.Pass()) |
38 , m_opaque(false) | 38 , m_opaque(false) |
39 { | 39 { |
40 } | 40 } |
41 | 41 |
42 BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater() | 42 BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater() |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 scoped_ptr<LayerTextureUpdater::Texture> BitmapCanvasLayerTextureUpdater::create
Texture(CCPrioritizedTextureManager* manager) | 46 scoped_ptr<LayerTextureUpdater::Texture> BitmapCanvasLayerTextureUpdater::create
Texture(PrioritizedTextureManager* manager) |
47 { | 47 { |
48 return scoped_ptr<LayerTextureUpdater::Texture>(new Texture(this, CCPrioriti
zedTexture::create(manager))); | 48 return scoped_ptr<LayerTextureUpdater::Texture>(new Texture(this, Prioritize
dTexture::create(manager))); |
49 } | 49 } |
50 | 50 |
51 LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampled
TexelFormat(GC3Denum textureFormat) | 51 LayerTextureUpdater::SampledTexelFormat BitmapCanvasLayerTextureUpdater::sampled
TexelFormat(GC3Denum textureFormat) |
52 { | 52 { |
53 // The component order may be bgra if we uploaded bgra pixels to rgba textur
es. | 53 // The component order may be bgra if we uploaded bgra pixels to rgba textur
es. |
54 return PlatformColor::sameComponentOrder(textureFormat) ? | 54 return PlatformColor::sameComponentOrder(textureFormat) ? |
55 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; | 55 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; |
56 } | 56 } |
57 | 57 |
58 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect
, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale,
IntRect& resultingOpaqueRect, CCRenderingStats& stats) | 58 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect
, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale,
IntRect& resultingOpaqueRect, RenderingStats& stats) |
59 { | 59 { |
60 if (m_canvasSize != contentRect.size()) { | 60 if (m_canvasSize != contentRect.size()) { |
61 m_canvasSize = contentRect.size(); | 61 m_canvasSize = contentRect.size(); |
62 m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width()
, m_canvasSize.height(), m_opaque)); | 62 m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width()
, m_canvasSize.height(), m_opaque)); |
63 } | 63 } |
64 | 64 |
65 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeigh
tScale, resultingOpaqueRect, stats); | 65 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeigh
tScale, resultingOpaqueRect, stats); |
66 } | 66 } |
67 | 67 |
68 void BitmapCanvasLayerTextureUpdater::updateTexture(CCTextureUpdateQueue& queue,
CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOf
fset, bool partialUpdate) | 68 void BitmapCanvasLayerTextureUpdater::updateTexture(TextureUpdateQueue& queue, P
rioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset
, bool partialUpdate) |
69 { | 69 { |
70 TextureUploader::Parameters upload = { texture, &m_canvas->getDevice()->acce
ssBitmap(false), NULL, { contentRect(), sourceRect, destOffset } }; | 70 TextureUploader::Parameters upload = { texture, &m_canvas->getDevice()->acce
ssBitmap(false), NULL, { contentRect(), sourceRect, destOffset } }; |
71 if (partialUpdate) | 71 if (partialUpdate) |
72 queue.appendPartialUpload(upload); | 72 queue.appendPartialUpload(upload); |
73 else | 73 else |
74 queue.appendFullUpload(upload); | 74 queue.appendFullUpload(upload); |
75 } | 75 } |
76 | 76 |
77 void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque) | 77 void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque) |
78 { | 78 { |
79 if (opaque != m_opaque) { | 79 if (opaque != m_opaque) { |
80 m_canvas.reset(); | 80 m_canvas.reset(); |
81 m_canvasSize = IntSize(); | 81 m_canvasSize = IntSize(); |
82 } | 82 } |
83 m_opaque = opaque; | 83 m_opaque = opaque; |
84 } | 84 } |
85 | 85 |
86 } // namespace cc | 86 } // namespace cc |
OLD | NEW |