Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: cc/CCDirectRenderer.cpp

Issue 10984053: cc: Use ui/gfx geometry types for the CCRenderPass and CCDrawQuad classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 // 64 //
65 // static 65 // static
66 FloatRect CCDirectRenderer::quadVertexRect() 66 FloatRect CCDirectRenderer::quadVertexRect()
67 { 67 {
68 return FloatRect(-0.5, -0.5, 1, 1); 68 return FloatRect(-0.5, -0.5, 1, 1);
69 } 69 }
70 70
71 // static 71 // static
72 void CCDirectRenderer::quadRectTransform(WebKit::WebTransformationMatrix* quadRe ctTransform, const WebKit::WebTransformationMatrix& quadTransform, const FloatRe ct& quadRect) 72 void CCDirectRenderer::quadRectTransform(WebKit::WebTransformationMatrix* quadRe ctTransform, const WebKit::WebTransformationMatrix& quadTransform, const ccmath: :FloatRect& quadRect)
73 { 73 {
74 *quadRectTransform = quadTransform; 74 *quadRectTransform = quadTransform;
75 quadRectTransform->translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * qu adRect.height() + quadRect.y()); 75 quadRectTransform->translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * qu adRect.height() + quadRect.y());
76 quadRectTransform->scaleNonUniform(quadRect.width(), quadRect.height()); 76 quadRectTransform->scaleNonUniform(quadRect.width(), quadRect.height());
77 } 77 }
78 78
79 // static 79 // static
80 void CCDirectRenderer::initializeMatrices(DrawingFrame& frame, const IntRect& dr awRect, bool flipY) 80 void CCDirectRenderer::initializeMatrices(DrawingFrame& frame, const ccmath::Int Rect& drawRect, bool flipY)
81 { 81 {
82 if (flipY) 82 if (flipY)
83 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ma xX(), drawRect.maxY(), drawRect.y()); 83 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ma x_x(), drawRect.max_y(), drawRect.y());
84 else 84 else
85 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ma xX(), drawRect.y(), drawRect.maxY()); 85 frame.projectionMatrix = orthoProjectionMatrix(drawRect.x(), drawRect.ma x_x(), drawRect.y(), drawRect.max_y());
86 frame.windowMatrix = windowMatrix(0, 0, drawRect.width(), drawRect.height()) ; 86 frame.windowMatrix = windowMatrix(0, 0, drawRect.width(), drawRect.height()) ;
87 frame.flippedY = flipY; 87 frame.flippedY = flipY;
88 } 88 }
89 89
90 // static 90 // static
91 IntRect CCDirectRenderer::moveScissorToWindowSpace(const DrawingFrame& frame, Fl oatRect scissorRect) 91 ccmath::IntRect CCDirectRenderer::moveScissorToWindowSpace(const DrawingFrame& f rame, ccmath::FloatRect scissorRect)
92 { 92 {
93 IntRect scissorRectInCanvasSpace = enclosingIntRect(scissorRect); 93 ccmath::IntRect scissorRectInCanvasSpace = scissorRect.EnclosingIntRect();
94 // The scissor coordinates must be supplied in viewport space so we need to offset 94 // The scissor coordinates must be supplied in viewport space so we need to offset
95 // by the relative position of the top left corner of the current render pas s. 95 // by the relative position of the top left corner of the current render pas s.
96 IntRect framebufferOutputRect = frame.currentRenderPass->outputRect(); 96 ccmath::IntRect framebufferOutputRect = frame.currentRenderPass->outputRect( );
97 scissorRectInCanvasSpace.setX(scissorRectInCanvasSpace.x() - framebufferOutp utRect.x()); 97 scissorRectInCanvasSpace.set_x(scissorRectInCanvasSpace.x() - framebufferOut putRect.x());
98 if (frame.flippedY && !frame.currentTexture) 98 if (frame.flippedY && !frame.currentTexture)
99 scissorRectInCanvasSpace.setY(framebufferOutputRect.height() - (scissorR ectInCanvasSpace.maxY() - framebufferOutputRect.y())); 99 scissorRectInCanvasSpace.set_y(framebufferOutputRect.height() - (scissor RectInCanvasSpace.max_y() - framebufferOutputRect.y()));
100 else 100 else
101 scissorRectInCanvasSpace.setY(scissorRectInCanvasSpace.y() - framebuffer OutputRect.y()); 101 scissorRectInCanvasSpace.set_y(scissorRectInCanvasSpace.y() - framebuffe rOutputRect.y());
102 return scissorRectInCanvasSpace; 102 return scissorRectInCanvasSpace;
103 } 103 }
104 104
105 CCDirectRenderer::CCDirectRenderer(CCRendererClient* client, CCResourceProvider* resourceProvider) 105 CCDirectRenderer::CCDirectRenderer(CCRendererClient* client, CCResourceProvider* resourceProvider)
106 : CCRenderer(client) 106 : CCRenderer(client)
107 , m_resourceProvider(resourceProvider) 107 , m_resourceProvider(resourceProvider)
108 { 108 {
109 } 109 }
110 110
111 CCDirectRenderer::~CCDirectRenderer() 111 CCDirectRenderer::~CCDirectRenderer()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 void CCDirectRenderer::drawFrame(const CCRenderPassList& renderPassesInDrawOrder , const CCRenderPassIdHashMap& renderPassesById) 163 void CCDirectRenderer::drawFrame(const CCRenderPassList& renderPassesInDrawOrder , const CCRenderPassIdHashMap& renderPassesById)
164 { 164 {
165 const CCRenderPass* rootRenderPass = renderPassesInDrawOrder.last(); 165 const CCRenderPass* rootRenderPass = renderPassesInDrawOrder.last();
166 ASSERT(rootRenderPass); 166 ASSERT(rootRenderPass);
167 167
168 DrawingFrame frame; 168 DrawingFrame frame;
169 frame.renderPassesById = &renderPassesById; 169 frame.renderPassesById = &renderPassesById;
170 frame.rootRenderPass = rootRenderPass; 170 frame.rootRenderPass = rootRenderPass;
171 frame.rootDamageRect = capabilities().usingPartialSwap ? rootRenderPass->dam ageRect() : rootRenderPass->outputRect(); 171 frame.rootDamageRect = capabilities().usingPartialSwap ? rootRenderPass->dam ageRect() : rootRenderPass->outputRect();
172 frame.rootDamageRect.intersect(IntRect(IntPoint::zero(), viewportSize())); 172 frame.rootDamageRect.Intersect(ccmath::IntRect(ccmath::IntPoint(), viewportS ize()));
173 173
174 beginDrawingFrame(frame); 174 beginDrawingFrame(frame);
175 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) 175 for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i)
176 drawRenderPass(frame, renderPassesInDrawOrder[i]); 176 drawRenderPass(frame, renderPassesInDrawOrder[i]);
177 finishDrawingFrame(frame); 177 finishDrawingFrame(frame);
178 } 178 }
179 179
180 void CCDirectRenderer::drawRenderPass(DrawingFrame& frame, const CCRenderPass* r enderPass) 180 void CCDirectRenderer::drawRenderPass(DrawingFrame& frame, const CCRenderPass* r enderPass)
181 { 181 {
182 if (!useRenderPass(frame, renderPass)) 182 if (!useRenderPass(frame, renderPass))
183 return; 183 return;
184 184
185 frame.scissorRectInRenderPassSpace = frame.currentRenderPass->outputRect(); 185 frame.scissorRectInRenderPassSpace = frame.currentRenderPass->outputRect();
186 if (frame.rootDamageRect != frame.rootRenderPass->outputRect()) { 186 if (frame.rootDamageRect != frame.rootRenderPass->outputRect()) {
187 WebTransformationMatrix inverseTransformToRoot = frame.currentRenderPass ->transformToRootTarget().inverse(); 187 WebTransformationMatrix inverseTransformToRoot = frame.currentRenderPass ->transformToRootTarget().inverse();
188 frame.scissorRectInRenderPassSpace.intersect(CCMathUtil::projectClippedR ect(inverseTransformToRoot, frame.rootDamageRect)); 188 frame.scissorRectInRenderPassSpace.Intersect(CCMathUtil::projectClippedR ect(inverseTransformToRoot, cc::FloatRect(frame.rootDamageRect)));
189 } 189 }
190 190
191 enableScissorTestRect(moveScissorToWindowSpace(frame, frame.scissorRectInRen derPassSpace)); 191 enableScissorTestRect(moveScissorToWindowSpace(frame, frame.scissorRectInRen derPassSpace));
192 clearFramebuffer(frame); 192 clearFramebuffer(frame);
193 193
194 const CCQuadList& quadList = renderPass->quadList(); 194 const CCQuadList& quadList = renderPass->quadList();
195 for (CCQuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) { 195 for (CCQuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) {
196 FloatRect quadScissorRect = frame.scissorRectInRenderPassSpace; 196 ccmath::FloatRect quadScissorRect = frame.scissorRectInRenderPassSpace;
197 quadScissorRect.intersect((*it)->clippedRectInTarget()); 197 quadScissorRect.Intersect((*it)->clippedRectInTarget());
198 if (!quadScissorRect.isEmpty()) { 198 if (!quadScissorRect.IsEmpty()) {
199 enableScissorTestRect(moveScissorToWindowSpace(frame, quadScissorRec t)); 199 enableScissorTestRect(moveScissorToWindowSpace(frame, quadScissorRec t));
200 drawQuad(frame, *it); 200 drawQuad(frame, *it);
201 } 201 }
202 } 202 }
203 203
204 CachedTexture* texture = m_renderPassTextures.get(renderPass->id()); 204 CachedTexture* texture = m_renderPassTextures.get(renderPass->id());
205 if (texture) 205 if (texture)
206 texture->setIsComplete(!renderPass->hasOcclusionFromOutsideTargetSurface ()); 206 texture->setIsComplete(!renderPass->hasOcclusionFromOutsideTargetSurface ());
207 } 207 }
208 208
(...skipping 19 matching lines...) Expand all
228 228
229 bool CCDirectRenderer::haveCachedResourcesForRenderPassId(CCRenderPass::Id id) c onst 229 bool CCDirectRenderer::haveCachedResourcesForRenderPassId(CCRenderPass::Id id) c onst
230 { 230 {
231 CachedTexture* texture = m_renderPassTextures.get(id); 231 CachedTexture* texture = m_renderPassTextures.get(id);
232 return texture && texture->id() && texture->isComplete(); 232 return texture && texture->id() && texture->isComplete();
233 } 233 }
234 234
235 // static 235 // static
236 IntSize CCDirectRenderer::renderPassTextureSize(const CCRenderPass* pass) 236 IntSize CCDirectRenderer::renderPassTextureSize(const CCRenderPass* pass)
237 { 237 {
238 return pass->outputRect().size(); 238 return cc::IntSize(pass->outputRect().size());
239 } 239 }
240 240
241 // static 241 // static
242 GC3Denum CCDirectRenderer::renderPassTextureFormat(const CCRenderPass*) 242 GC3Denum CCDirectRenderer::renderPassTextureFormat(const CCRenderPass*)
243 { 243 {
244 return GraphicsContext3D::RGBA; 244 return GraphicsContext3D::RGBA;
245 } 245 }
246 246
247 } 247 }
OLDNEW
« no previous file with comments | « cc/CCDirectRenderer.h ('k') | cc/CCDrawQuad.h » ('j') | cc/math/clamp.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698