OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/direct_renderer.h" | 5 #include "cc/direct_renderer.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 const RenderPass* renderPassInFrame = it->second; | 137 const RenderPass* renderPassInFrame = it->second; |
138 const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame) ; | 138 const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame) ; |
139 GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame); | 139 GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame); |
140 CachedResource* texture = passIterator->second; | 140 CachedResource* texture = passIterator->second; |
141 DCHECK(texture); | 141 DCHECK(texture); |
142 | 142 |
143 bool sizeAppropriate = texture->size().width() >= requiredSize.width() & & | 143 bool sizeAppropriate = texture->size().width() >= requiredSize.width() & & |
144 texture->size().height() >= requiredSize.height() ; | 144 texture->size().height() >= requiredSize.height() ; |
145 if (texture->id() && (!sizeAppropriate || texture->format() != requiredF ormat)) | 145 if (texture->id() && (!sizeAppropriate || texture->format() != requiredF ormat)) |
146 texture->Free(); | 146 texture->Free(); |
147 else if (texture->size() != requiredSize) | |
danakj
2013/01/24 23:38:04
What happens if you texture->setIsComplete(false)
| |
148 texture->setNeedsFullClear(true); | |
danakj
2013/01/24 23:23:18
Doesn't this clear the whole texture every frame o
danakj
2013/01/24 23:39:25
Before it would have reallocated a new texture of
| |
147 } | 149 } |
148 | 150 |
149 // Delete RenderPass textures from the previous frame that will not be used again. | 151 // Delete RenderPass textures from the previous frame that will not be used again. |
150 for (size_t i = 0; i < passesToDelete.size(); ++i) | 152 for (size_t i = 0; i < passesToDelete.size(); ++i) |
151 m_renderPassTextures.erase(passesToDelete[i]); | 153 m_renderPassTextures.erase(passesToDelete[i]); |
152 | 154 |
153 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { | 155 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { |
154 if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id)) { | 156 if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id)) { |
155 scoped_ptr<CachedResource> texture = CachedResource::create(m_resource Provider); | 157 scoped_ptr<CachedResource> texture = CachedResource::create(m_resource Provider); |
156 m_renderPassTextures.set(renderPassesInDrawOrder[i]->id, texture.Pas s()); | 158 m_renderPassTextures.set(renderPassesInDrawOrder[i]->id, texture.Pas s()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 return; | 235 return; |
234 | 236 |
235 bool usingScissorAsOptimization = capabilities().usingPartialSwap; | 237 bool usingScissorAsOptimization = capabilities().usingPartialSwap; |
236 gfx::RectF renderPassScissor; | 238 gfx::RectF renderPassScissor; |
237 | 239 |
238 if (usingScissorAsOptimization) { | 240 if (usingScissorAsOptimization) { |
239 renderPassScissor = computeScissorRectForRenderPass(frame); | 241 renderPassScissor = computeScissorRectForRenderPass(frame); |
240 setScissorTestRect(moveScissorToWindowSpace(frame, renderPassScissor)); | 242 setScissorTestRect(moveScissorToWindowSpace(frame, renderPassScissor)); |
241 } | 243 } |
242 | 244 |
243 if (frame.currentRenderPass != frame.rootRenderPass || m_client->shouldClear RootRenderPass()) | 245 bool isRootPass = frame.currentRenderPass == frame.rootRenderPass; |
244 clearFramebuffer(frame); | 246 if (!isRootPass || m_client->shouldClearRootRenderPass()) { |
247 CachedResource* texture = m_renderPassTextures.get(frame.currentRenderPa ss->id); | |
248 DCHECK(texture); | |
249 bool fullClear = false; | |
250 if (!isRootPass) | |
251 fullClear = texture->needsFullClear(); | |
252 clearFramebuffer(frame, fullClear); | |
253 texture->setNeedsFullClear(false); | |
254 } | |
245 | 255 |
246 const QuadList& quadList = renderPass->quad_list; | 256 const QuadList& quadList = renderPass->quad_list; |
247 for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) { | 257 for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) { |
248 const DrawQuad& quad = *(*it); | 258 const DrawQuad& quad = *(*it); |
249 bool shouldSkipQuad = false; | 259 bool shouldSkipQuad = false; |
250 | 260 |
251 if (usingScissorAsOptimization) | 261 if (usingScissorAsOptimization) |
252 setScissorStateForQuadWithRenderPassScissor(frame, quad, renderPassS cissor, &shouldSkipQuad); | 262 setScissorStateForQuadWithRenderPassScissor(frame, quad, renderPassS cissor, &shouldSkipQuad); |
253 else | 263 else |
254 setScissorStateForQuad(frame, quad); | 264 setScissorStateForQuad(frame, quad); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 return pass->output_rect.size(); | 308 return pass->output_rect.size(); |
299 } | 309 } |
300 | 310 |
301 // static | 311 // static |
302 GLenum DirectRenderer::renderPassTextureFormat(const RenderPass*) | 312 GLenum DirectRenderer::renderPassTextureFormat(const RenderPass*) |
303 { | 313 { |
304 return GL_RGBA; | 314 return GL_RGBA; |
305 } | 315 } |
306 | 316 |
307 } // namespace cc | 317 } // namespace cc |
OLD | NEW |