| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCDirectRenderer.h" | 7 #include "CCDirectRenderer.h" |
| 8 | 8 |
| 9 #include "CCMathUtil.h" | 9 #include "CCMathUtil.h" |
| 10 #include <public/WebTransformationMatrix.h> | 10 #include <public/WebTransformationMatrix.h> |
| 11 #include <vector> |
| 11 | 12 |
| 12 using WebKit::WebTransformationMatrix; | 13 using WebKit::WebTransformationMatrix; |
| 13 | 14 |
| 14 static WebTransformationMatrix orthoProjectionMatrix(float left, float right, fl
oat bottom, float top) | 15 static WebTransformationMatrix orthoProjectionMatrix(float left, float right, fl
oat bottom, float top) |
| 15 { | 16 { |
| 16 // Use the standard formula to map the clipping frustum to the cube from | 17 // Use the standard formula to map the clipping frustum to the cube from |
| 17 // [-1, -1, -1] to [1, 1, 1]. | 18 // [-1, -1, -1] to [1, 1, 1]. |
| 18 float deltaX = right - left; | 19 float deltaX = right - left; |
| 19 float deltaY = top - bottom; | 20 float deltaY = top - bottom; |
| 20 WebTransformationMatrix proj; | 21 WebTransformationMatrix proj; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 , m_resourceProvider(resourceProvider) | 108 , m_resourceProvider(resourceProvider) |
| 108 { | 109 { |
| 109 } | 110 } |
| 110 | 111 |
| 111 CCDirectRenderer::~CCDirectRenderer() | 112 CCDirectRenderer::~CCDirectRenderer() |
| 112 { | 113 { |
| 113 } | 114 } |
| 114 | 115 |
| 115 void CCDirectRenderer::decideRenderPassAllocationsForFrame(const CCRenderPassLis
t& renderPassesInDrawOrder) | 116 void CCDirectRenderer::decideRenderPassAllocationsForFrame(const CCRenderPassLis
t& renderPassesInDrawOrder) |
| 116 { | 117 { |
| 117 HashMap<CCRenderPass::Id, const CCRenderPass*> renderPassesInFrame; | 118 base::hash_map<CCRenderPass::Id, const CCRenderPass*> renderPassesInFrame; |
| 118 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) | 119 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) |
| 119 renderPassesInFrame.set(renderPassesInDrawOrder[i]->id(), renderPassesIn
DrawOrder[i]); | 120 renderPassesInFrame.insert(std::pair<CCRenderPass::Id, const CCRenderPas
s*>(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i])); |
| 120 | 121 |
| 121 Vector<CCRenderPass::Id> passesToDelete; | 122 std::vector<CCRenderPass::Id> passesToDelete; |
| 122 HashMap<CCRenderPass::Id, OwnPtr<CachedTexture> >::const_iterator passIterat
or; | 123 ScopedPtrHashMap<CCRenderPass::Id, CachedTexture>::const_iterator passIterat
or; |
| 123 for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPa
ssTextures.end(); ++passIterator) { | 124 for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPa
ssTextures.end(); ++passIterator) { |
| 124 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 125 base::hash_map<CCRenderPass::Id, const CCRenderPass*>::const_iterator it
= renderPassesInFrame.find(passIterator->first); |
| 125 const CCRenderPass* renderPassInFrame = renderPassesInFrame.get(passIter
ator->key); | 126 if (it == renderPassesInFrame.end()) { |
| 126 #else | 127 passesToDelete.push_back(passIterator->first); |
| 127 const CCRenderPass* renderPassInFrame = renderPassesInFrame.get(passIter
ator->first); | |
| 128 #endif | |
| 129 if (!renderPassInFrame) { | |
| 130 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | |
| 131 passesToDelete.append(passIterator->key); | |
| 132 #else | |
| 133 passesToDelete.append(passIterator->first); | |
| 134 #endif | |
| 135 continue; | 128 continue; |
| 136 } | 129 } |
| 137 | 130 |
| 131 const CCRenderPass* renderPassInFrame = it->second; |
| 138 const IntSize& requiredSize = renderPassTextureSize(renderPassInFrame); | 132 const IntSize& requiredSize = renderPassTextureSize(renderPassInFrame); |
| 139 GC3Denum requiredFormat = renderPassTextureFormat(renderPassInFrame); | 133 GC3Denum requiredFormat = renderPassTextureFormat(renderPassInFrame); |
| 140 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 134 CachedTexture* texture = passIterator->second; |
| 141 CachedTexture* texture = passIterator->value.get(); | |
| 142 #else | |
| 143 CachedTexture* texture = passIterator->second.get(); | |
| 144 #endif | |
| 145 ASSERT(texture); | 135 ASSERT(texture); |
| 146 | 136 |
| 147 if (texture->id() && (texture->size() != requiredSize || texture->format
() != requiredFormat)) | 137 if (texture->id() && (texture->size() != requiredSize || texture->format
() != requiredFormat)) |
| 148 texture->free(); | 138 texture->free(); |
| 149 } | 139 } |
| 150 | 140 |
| 151 // Delete RenderPass textures from the previous frame that will not be used
again. | 141 // Delete RenderPass textures from the previous frame that will not be used
again. |
| 152 for (size_t i = 0; i < passesToDelete.size(); ++i) | 142 for (size_t i = 0; i < passesToDelete.size(); ++i) |
| 153 m_renderPassTextures.remove(passesToDelete[i]); | 143 m_renderPassTextures.erase(passesToDelete[i]); |
| 154 | 144 |
| 155 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { | 145 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) { |
| 156 if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id())) { | 146 if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id())) { |
| 157 OwnPtr<CachedTexture> texture = CachedTexture::create(m_resourceProv
ider); | 147 scoped_ptr<CachedTexture> texture = CachedTexture::create(m_resourcePr
ovider); |
| 158 m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), texture.r
elease()); | 148 m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), texture.P
ass()); |
| 159 } | 149 } |
| 160 } | 150 } |
| 161 } | 151 } |
| 162 | 152 |
| 163 void CCDirectRenderer::drawFrame(const CCRenderPassList& renderPassesInDrawOrder
, const CCRenderPassIdHashMap& renderPassesById) | 153 void CCDirectRenderer::drawFrame(const CCRenderPassList& renderPassesInDrawOrder
, const CCRenderPassIdHashMap& renderPassesById) |
| 164 { | 154 { |
| 165 const CCRenderPass* rootRenderPass = renderPassesInDrawOrder.last(); | 155 const CCRenderPass* rootRenderPass = renderPassesInDrawOrder.last(); |
| 166 ASSERT(rootRenderPass); | 156 ASSERT(rootRenderPass); |
| 167 | 157 |
| 168 DrawingFrame frame; | 158 DrawingFrame frame; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return pass->outputRect().size(); | 228 return pass->outputRect().size(); |
| 239 } | 229 } |
| 240 | 230 |
| 241 // static | 231 // static |
| 242 GC3Denum CCDirectRenderer::renderPassTextureFormat(const CCRenderPass*) | 232 GC3Denum CCDirectRenderer::renderPassTextureFormat(const CCRenderPass*) |
| 243 { | 233 { |
| 244 return GraphicsContext3D::RGBA; | 234 return GraphicsContext3D::RGBA; |
| 245 } | 235 } |
| 246 | 236 |
| 247 } | 237 } |
| OLD | NEW |