OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/texture_layer.h" | 7 #include "cc/texture_layer.h" |
8 | 8 |
9 #include "CCLayerTreeHost.h" | 9 #include "CCLayerTreeHost.h" |
10 #include "CCTextureLayerImpl.h" | 10 #include "CCTextureLayerImpl.h" |
11 #include "cc/texture_layer_client.h" | 11 #include "cc/texture_layer_client.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 scoped_refptr<TextureLayerChromium> TextureLayerChromium::create(TextureLayerChr
omiumClient* client) | 15 scoped_refptr<TextureLayer> TextureLayer::create(TextureLayerClient* client) |
16 { | 16 { |
17 return scoped_refptr<TextureLayerChromium>(new TextureLayerChromium(client))
; | 17 return scoped_refptr<TextureLayer>(new TextureLayer(client)); |
18 } | 18 } |
19 | 19 |
20 TextureLayerChromium::TextureLayerChromium(TextureLayerChromiumClient* client) | 20 TextureLayer::TextureLayer(TextureLayerClient* client) |
21 : LayerChromium() | 21 : Layer() |
22 , m_client(client) | 22 , m_client(client) |
23 , m_flipped(true) | 23 , m_flipped(true) |
24 , m_uvRect(0, 0, 1, 1) | 24 , m_uvRect(0, 0, 1, 1) |
25 , m_premultipliedAlpha(true) | 25 , m_premultipliedAlpha(true) |
26 , m_rateLimitContext(false) | 26 , m_rateLimitContext(false) |
27 , m_contextLost(false) | 27 , m_contextLost(false) |
28 , m_textureId(0) | 28 , m_textureId(0) |
29 { | 29 { |
30 } | 30 } |
31 | 31 |
32 TextureLayerChromium::~TextureLayerChromium() | 32 TextureLayer::~TextureLayer() |
33 { | 33 { |
34 if (layerTreeHost()) { | 34 if (layerTreeHost()) { |
35 if (m_textureId) | 35 if (m_textureId) |
36 layerTreeHost()->acquireLayerTextures(); | 36 layerTreeHost()->acquireLayerTextures(); |
37 if (m_rateLimitContext && m_client) | 37 if (m_rateLimitContext && m_client) |
38 layerTreeHost()->stopRateLimiter(m_client->context()); | 38 layerTreeHost()->stopRateLimiter(m_client->context()); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 scoped_ptr<CCLayerImpl> TextureLayerChromium::createCCLayerImpl() | 42 scoped_ptr<LayerImpl> TextureLayer::createLayerImpl() |
43 { | 43 { |
44 return CCTextureLayerImpl::create(m_layerId).PassAs<CCLayerImpl>(); | 44 return TextureLayerImpl::create(m_layerId).PassAs<LayerImpl>(); |
45 } | 45 } |
46 | 46 |
47 void TextureLayerChromium::setFlipped(bool flipped) | 47 void TextureLayer::setFlipped(bool flipped) |
48 { | 48 { |
49 m_flipped = flipped; | 49 m_flipped = flipped; |
50 setNeedsCommit(); | 50 setNeedsCommit(); |
51 } | 51 } |
52 | 52 |
53 void TextureLayerChromium::setUVRect(const FloatRect& rect) | 53 void TextureLayer::setUVRect(const FloatRect& rect) |
54 { | 54 { |
55 m_uvRect = rect; | 55 m_uvRect = rect; |
56 setNeedsCommit(); | 56 setNeedsCommit(); |
57 } | 57 } |
58 | 58 |
59 void TextureLayerChromium::setPremultipliedAlpha(bool premultipliedAlpha) | 59 void TextureLayer::setPremultipliedAlpha(bool premultipliedAlpha) |
60 { | 60 { |
61 m_premultipliedAlpha = premultipliedAlpha; | 61 m_premultipliedAlpha = premultipliedAlpha; |
62 setNeedsCommit(); | 62 setNeedsCommit(); |
63 } | 63 } |
64 | 64 |
65 void TextureLayerChromium::setRateLimitContext(bool rateLimit) | 65 void TextureLayer::setRateLimitContext(bool rateLimit) |
66 { | 66 { |
67 if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost()) | 67 if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost()) |
68 layerTreeHost()->stopRateLimiter(m_client->context()); | 68 layerTreeHost()->stopRateLimiter(m_client->context()); |
69 | 69 |
70 m_rateLimitContext = rateLimit; | 70 m_rateLimitContext = rateLimit; |
71 } | 71 } |
72 | 72 |
73 void TextureLayerChromium::setTextureId(unsigned id) | 73 void TextureLayer::setTextureId(unsigned id) |
74 { | 74 { |
75 if (m_textureId == id) | 75 if (m_textureId == id) |
76 return; | 76 return; |
77 if (m_textureId && layerTreeHost()) | 77 if (m_textureId && layerTreeHost()) |
78 layerTreeHost()->acquireLayerTextures(); | 78 layerTreeHost()->acquireLayerTextures(); |
79 m_textureId = id; | 79 m_textureId = id; |
80 setNeedsCommit(); | 80 setNeedsCommit(); |
81 } | 81 } |
82 | 82 |
83 void TextureLayerChromium::willModifyTexture() | 83 void TextureLayer::willModifyTexture() |
84 { | 84 { |
85 if (layerTreeHost()) | 85 if (layerTreeHost()) |
86 layerTreeHost()->acquireLayerTextures(); | 86 layerTreeHost()->acquireLayerTextures(); |
87 } | 87 } |
88 | 88 |
89 void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect) | 89 void TextureLayer::setNeedsDisplayRect(const FloatRect& dirtyRect) |
90 { | 90 { |
91 LayerChromium::setNeedsDisplayRect(dirtyRect); | 91 Layer::setNeedsDisplayRect(dirtyRect); |
92 | 92 |
93 if (m_rateLimitContext && m_client && layerTreeHost()) | 93 if (m_rateLimitContext && m_client && layerTreeHost()) |
94 layerTreeHost()->startRateLimiter(m_client->context()); | 94 layerTreeHost()->startRateLimiter(m_client->context()); |
95 } | 95 } |
96 | 96 |
97 void TextureLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) | 97 void TextureLayer::setLayerTreeHost(LayerTreeHost* host) |
98 { | 98 { |
99 if (m_textureId && layerTreeHost() && host != layerTreeHost()) | 99 if (m_textureId && layerTreeHost() && host != layerTreeHost()) |
100 layerTreeHost()->acquireLayerTextures(); | 100 layerTreeHost()->acquireLayerTextures(); |
101 LayerChromium::setLayerTreeHost(host); | 101 Layer::setLayerTreeHost(host); |
102 } | 102 } |
103 | 103 |
104 bool TextureLayerChromium::drawsContent() const | 104 bool TextureLayer::drawsContent() const |
105 { | 105 { |
106 return (m_client || m_textureId) && !m_contextLost && LayerChromium::drawsCo
ntent(); | 106 return (m_client || m_textureId) && !m_contextLost && Layer::drawsContent(); |
107 } | 107 } |
108 | 108 |
109 void TextureLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusion
Tracker*, CCRenderingStats&) | 109 void TextureLayer::update(TextureUpdateQueue& queue, const OcclusionTracker*, Re
nderingStats&) |
110 { | 110 { |
111 if (m_client) { | 111 if (m_client) { |
112 m_textureId = m_client->prepareTexture(queue); | 112 m_textureId = m_client->prepareTexture(queue); |
113 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != Grap
hicsContext3D::NO_ERROR; | 113 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != Grap
hicsContext3D::NO_ERROR; |
114 } | 114 } |
115 | 115 |
116 m_needsDisplay = false; | 116 m_needsDisplay = false; |
117 } | 117 } |
118 | 118 |
119 void TextureLayerChromium::pushPropertiesTo(CCLayerImpl* layer) | 119 void TextureLayer::pushPropertiesTo(LayerImpl* layer) |
120 { | 120 { |
121 LayerChromium::pushPropertiesTo(layer); | 121 Layer::pushPropertiesTo(layer); |
122 | 122 |
123 CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer); | 123 TextureLayerImpl* textureLayer = static_cast<TextureLayerImpl*>(layer); |
124 textureLayer->setFlipped(m_flipped); | 124 textureLayer->setFlipped(m_flipped); |
125 textureLayer->setUVRect(m_uvRect); | 125 textureLayer->setUVRect(m_uvRect); |
126 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); | 126 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); |
127 textureLayer->setTextureId(m_textureId); | 127 textureLayer->setTextureId(m_textureId); |
128 } | 128 } |
129 | 129 |
130 } | 130 } |
OLD | NEW |