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

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

Issue 794343006: Move all non-program cache functions out of GrGpuGL_program.cpp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | src/gpu/gl/GrGpuGL_program.cpp » ('j') | 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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 fHWScissorSettings.fEnabled = kYes_TriState; 1337 fHWScissorSettings.fEnabled = kYes_TriState;
1338 } 1338 }
1339 return; 1339 return;
1340 } 1340 }
1341 } 1341 }
1342 1342
1343 // See fall through note above 1343 // See fall through note above
1344 this->disableScissor(); 1344 this->disableScissor();
1345 } 1345 }
1346 1346
1347 bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState) {
1348 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
1349 SkASSERT(optState.getRenderTarget());
1350
1351 if (kStencilPath_DrawType == optState.drawType()) {
1352 const GrRenderTarget* rt = optState.getRenderTarget();
1353 SkISize size;
1354 size.set(rt->width(), rt->height());
1355 this->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), s ize, rt->origin());
1356 } else {
1357 this->flushMiscFixedFunctionState(optState);
1358
1359 fCurrentProgram.reset(fProgramCache->getProgram(optState));
1360 if (NULL == fCurrentProgram.get()) {
1361 SkDEBUGFAIL("Failed to create program!");
1362 return false;
1363 }
1364
1365 fCurrentProgram.get()->ref();
1366
1367 GrGLuint programID = fCurrentProgram->programID();
1368 if (fHWProgramID != programID) {
1369 GL_CALL(UseProgram(programID));
1370 fHWProgramID = programID;
1371 }
1372
1373 this->flushBlend(optState);
1374
1375 fCurrentProgram->setData(optState);
1376 }
1377
1378 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTa rget());
1379 this->flushStencil(optState.getStencil(), optState.drawType());
1380 this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->or igin());
1381 this->flushAAState(optState);
1382
1383 // This must come after textures are flushed because a texture may need
1384 // to be msaa-resolved (which will modify bound FBO state).
1385 this->flushRenderTarget(glRT, NULL);
1386
1387 return true;
1388 }
1389
1390 void GrGpuGL::setupGeometry(const GrOptDrawState& optState,
1391 const GrDrawTarget::DrawInfo& info,
1392 size_t* indexOffsetInBytes) {
1393 GrGLVertexBuffer* vbuf;
1394 vbuf = (GrGLVertexBuffer*) info.vertexBuffer();
1395
1396 SkASSERT(vbuf);
1397 SkASSERT(!vbuf->isMapped());
1398
1399 GrGLIndexBuffer* ibuf = NULL;
1400 if (info.isIndexed()) {
1401 SkASSERT(indexOffsetInBytes);
1402
1403 *indexOffsetInBytes = 0;
1404 ibuf = (GrGLIndexBuffer*)info.indexBuffer();
1405
1406 SkASSERT(ibuf);
1407 SkASSERT(!ibuf->isMapped());
1408 *indexOffsetInBytes += ibuf->baseOffset();
1409 }
1410 GrGLAttribArrayState* attribState =
1411 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf);
1412
1413 if (fCurrentProgram->hasVertexShader()) {
1414 const GrGeometryProcessor* gp = optState.getGeometryProcessor();
1415
1416 GrGLsizei stride = static_cast<GrGLsizei>(gp->getVertexStride());
1417
1418 size_t vertexOffsetInBytes = stride * info.startVertex();
1419
1420 vertexOffsetInBytes += vbuf->baseOffset();
1421
1422 const SkTArray<GrGeometryProcessor::GrAttribute, true>& attribs = gp->ge tAttribs();
1423 int vaCount = attribs.count();
1424 uint32_t usedAttribArraysMask = 0;
1425 size_t offset = 0;
1426
1427 for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) {
1428 usedAttribArraysMask |= (1 << attribIndex);
1429 GrVertexAttribType attribType = attribs[attribIndex].fType;
1430 attribState->set(this,
1431 attribIndex,
1432 vbuf,
1433 GrGLAttribTypeToLayout(attribType).fCount,
1434 GrGLAttribTypeToLayout(attribType).fType,
1435 GrGLAttribTypeToLayout(attribType).fNormalized,
1436 stride,
1437 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o ffset));
1438 offset += attribs[attribIndex].fOffset;
1439 }
1440 attribState->disableUnusedArrays(this, usedAttribArraysMask);
1441 }
1442 }
1443
1444 void GrGpuGL::buildProgramDesc(const GrOptDrawState& optState,
1445 const GrProgramDesc::DescInfo& descInfo,
1446 GrGpu::DrawType drawType,
1447 GrProgramDesc* desc) {
1448 if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, desc) ) {
1449 SkDEBUGFAIL("Failed to generate GL program descriptor");
1450 }
1451 }
1452
1347 void GrGpuGL::disableScissor() { 1453 void GrGpuGL::disableScissor() {
1348 if (kNo_TriState != fHWScissorSettings.fEnabled) { 1454 if (kNo_TriState != fHWScissorSettings.fEnabled) {
1349 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); 1455 GL_CALL(Disable(GR_GL_SCISSOR_TEST));
1350 fHWScissorSettings.fEnabled = kNo_TriState; 1456 fHWScissorSettings.fEnabled = kNo_TriState;
1351 return; 1457 return;
1352 } 1458 }
1353 } 1459 }
1354 1460
1355 void GrGpuGL::onClear(GrRenderTarget* target, const SkIRect* rect, GrColor color , 1461 void GrGpuGL::onClear(GrRenderTarget* target, const SkIRect* rect, GrColor color ,
1356 bool canIgnoreRect) { 1462 bool canIgnoreRect) {
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 this->setVertexArrayID(gpu, 0); 2695 this->setVertexArrayID(gpu, 0);
2590 } 2696 }
2591 int attrCount = gpu->glCaps().maxVertexAttributes(); 2697 int attrCount = gpu->glCaps().maxVertexAttributes();
2592 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2698 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2593 fDefaultVertexArrayAttribState.resize(attrCount); 2699 fDefaultVertexArrayAttribState.resize(attrCount);
2594 } 2700 }
2595 attribState = &fDefaultVertexArrayAttribState; 2701 attribState = &fDefaultVertexArrayAttribState;
2596 } 2702 }
2597 return attribState; 2703 return attribState;
2598 } 2704 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698