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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 passesToDelete.push_back(passIterator->first); | 127 passesToDelete.push_back(passIterator->first); |
128 continue; | 128 continue; |
129 } | 129 } |
130 | 130 |
131 const RenderPass* renderPassInFrame = it->second; | 131 const RenderPass* renderPassInFrame = it->second; |
132 const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame)
; | 132 const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame)
; |
133 GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame); | 133 GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame); |
134 CachedResource* texture = passIterator->second; | 134 CachedResource* texture = passIterator->second; |
135 DCHECK(texture); | 135 DCHECK(texture); |
136 | 136 |
137 if (texture->id() && (texture->size() != requiredSize || texture->format
() != requiredFormat)) | 137 bool sizeAppropriate = texture->size().width() >= requiredSize.width() &
& |
| 138 texture->size().height() >= requiredSize.height()
; |
| 139 if (texture->id() && (!sizeAppropriate || texture->format() != requiredF
ormat)) |
138 texture->Free(); | 140 texture->Free(); |
139 } | 141 } |
140 | 142 |
141 // Delete RenderPass textures from the previous frame that will not be used
again. | 143 // Delete RenderPass textures from the previous frame that will not be used
again. |
142 for (size_t i = 0; i < passesToDelete.size(); ++i) | 144 for (size_t i = 0; i < passesToDelete.size(); ++i) |
143 m_renderPassTextures.erase(passesToDelete[i]); | 145 m_renderPassTextures.erase(passesToDelete[i]); |
144 | 146 |
145 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { | 147 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { |
146 if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id)) { | 148 if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id)) { |
147 scoped_ptr<CachedResource> texture = CachedResource::create(m_resource
Provider); | 149 scoped_ptr<CachedResource> texture = CachedResource::create(m_resource
Provider); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 262 |
261 if (renderPass == frame.rootRenderPass) { | 263 if (renderPass == frame.rootRenderPass) { |
262 bindFramebufferToOutputSurface(frame); | 264 bindFramebufferToOutputSurface(frame); |
263 initializeMatrices(frame, renderPass->output_rect, flippedFramebuffer())
; | 265 initializeMatrices(frame, renderPass->output_rect, flippedFramebuffer())
; |
264 setDrawViewportSize(renderPass->output_rect.size()); | 266 setDrawViewportSize(renderPass->output_rect.size()); |
265 return true; | 267 return true; |
266 } | 268 } |
267 | 269 |
268 CachedResource* texture = m_renderPassTextures.get(renderPass->id); | 270 CachedResource* texture = m_renderPassTextures.get(renderPass->id); |
269 DCHECK(texture); | 271 DCHECK(texture); |
270 if (!texture->id() && !texture->Allocate(Renderer::ImplPool, renderPassTextu
reSize(renderPass), renderPassTextureFormat(renderPass), ResourceProvider::Textu
reUsageFramebuffer)) | 272 |
| 273 gfx::Size size = renderPassTextureSize(renderPass); |
| 274 if (!texture->id() && !texture->Allocate(Renderer::ImplPool, size, renderPas
sTextureFormat(renderPass), ResourceProvider::TextureUsageFramebuffer)) |
271 return false; | 275 return false; |
272 | 276 |
273 return bindFramebufferToTexture(frame, texture, renderPass->output_rect); | 277 return bindFramebufferToTexture(frame, texture, renderPass->output_rect); |
274 } | 278 } |
275 | 279 |
276 bool DirectRenderer::haveCachedResourcesForRenderPassId(RenderPass::Id id) const | 280 bool DirectRenderer::haveCachedResourcesForRenderPassId(RenderPass::Id id) const |
277 { | 281 { |
278 CachedResource* texture = m_renderPassTextures.get(id); | 282 CachedResource* texture = m_renderPassTextures.get(id); |
279 return texture && texture->id() && texture->isComplete(); | 283 return texture && texture->id() && texture->isComplete(); |
280 } | 284 } |
281 | 285 |
282 // static | 286 // static |
283 gfx::Size DirectRenderer::renderPassTextureSize(const RenderPass* pass) | 287 gfx::Size DirectRenderer::renderPassTextureSize(const RenderPass* pass) |
284 { | 288 { |
285 return pass->output_rect.size(); | 289 return pass->output_rect.size(); |
286 } | 290 } |
287 | 291 |
288 // static | 292 // static |
289 GLenum DirectRenderer::renderPassTextureFormat(const RenderPass*) | 293 GLenum DirectRenderer::renderPassTextureFormat(const RenderPass*) |
290 { | 294 { |
291 return GL_RGBA; | 295 return GL_RGBA; |
292 } | 296 } |
293 | 297 |
294 } // namespace cc | 298 } // namespace cc |
OLD | NEW |