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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 218763006: Use glInvalidateFramebuffer() when it is supported. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 g = GrColorUnpackG(color) * scaleRGB; 1289 g = GrColorUnpackG(color) * scaleRGB;
1290 b = GrColorUnpackB(color) * scaleRGB; 1290 b = GrColorUnpackB(color) * scaleRGB;
1291 1291
1292 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); 1292 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
1293 fHWWriteToColor = kYes_TriState; 1293 fHWWriteToColor = kYes_TriState;
1294 GL_CALL(ClearColor(r, g, b, a)); 1294 GL_CALL(ClearColor(r, g, b, a));
1295 GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); 1295 GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
1296 } 1296 }
1297 1297
1298 void GrGpuGL::discard(GrRenderTarget* renderTarget) { 1298 void GrGpuGL::discard(GrRenderTarget* renderTarget) {
1299 if (!this->caps()->discardRenderTargetSupport()) {
1300 return;
1301 }
1299 if (NULL == renderTarget) { 1302 if (NULL == renderTarget) {
1300 renderTarget = this->drawState()->getRenderTarget(); 1303 renderTarget = this->drawState()->getRenderTarget();
1301 if (NULL == renderTarget) { 1304 if (NULL == renderTarget) {
1302 return; 1305 return;
1303 } 1306 }
1304 } 1307 }
1305 1308
1306 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); 1309 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
1307 if (renderTarget != fHWBoundRenderTarget) { 1310 if (renderTarget != fHWBoundRenderTarget) {
1308 fHWBoundRenderTarget = NULL; 1311 fHWBoundRenderTarget = NULL;
1309 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); 1312 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
1310 } 1313 }
1311 GrGLenum attachments[] = { GR_GL_COLOR }; 1314 switch (this->glCaps().invalidateFBType()) {
1312 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments), a ttachments)); 1315 case GrGLCaps::kNone_FBFetchType:
1316 GrCrash("Should never get here.");
1317 break;
1318 case GrGLCaps::kInvalidate_InvalidateFBType:
1319 if (0 == glRT->renderFBOID()) {
1320 // When rendering to the default framebuffer the legal values f or attachments
1321 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment
1322 // types.
1323 static const GrGLenum attachments[] = { GR_GL_COLOR };
1324 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments),
1325 attachments));
1326 } else {
1327 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 };
1328 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments),
1329 attachments));
1330 }
1331 break;
1332 case GrGLCaps::kDiscard_InvalidateFBType: {
1333 static const GrGLenum attachments[] = { GR_GL_COLOR };
1334 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachm ents),
1335 attachments));
1336 break;
1337 }
1338 }
1313 renderTarget->flagAsResolved(); 1339 renderTarget->flagAsResolved();
1314 } 1340 }
1315 1341
1316 1342
1317 void GrGpuGL::clearStencil() { 1343 void GrGpuGL::clearStencil() {
1318 if (NULL == this->getDrawState().getRenderTarget()) { 1344 if (NULL == this->getDrawState().getRenderTarget()) {
1319 return; 1345 return;
1320 } 1346 }
1321 1347
1322 this->flushRenderTarget(&SkIRect::EmptyIRect()); 1348 this->flushRenderTarget(&SkIRect::EmptyIRect());
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 this->setVertexArrayID(gpu, 0); 2834 this->setVertexArrayID(gpu, 0);
2809 } 2835 }
2810 int attrCount = gpu->glCaps().maxVertexAttributes(); 2836 int attrCount = gpu->glCaps().maxVertexAttributes();
2811 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2837 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2812 fDefaultVertexArrayAttribState.resize(attrCount); 2838 fDefaultVertexArrayAttribState.resize(attrCount);
2813 } 2839 }
2814 attribState = &fDefaultVertexArrayAttribState; 2840 attribState = &fDefaultVertexArrayAttribState;
2815 } 2841 }
2816 return attribState; 2842 return attribState;
2817 } 2843 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698