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

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

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 11 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
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLGpuProgramCache.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 "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
11 #include "GrGLTextureRenderTarget.h" 11 #include "GrGLTextureRenderTarget.h"
12 #include "GrGpuResourceCacheAccess.h" 12 #include "GrGpuResourceCacheAccess.h"
13 #include "GrOptDrawState.h" 13 #include "GrPipeline.h"
14 #include "GrSurfacePriv.h" 14 #include "GrSurfacePriv.h"
15 #include "GrTemplates.h" 15 #include "GrTemplates.h"
16 #include "GrTexturePriv.h" 16 #include "GrTexturePriv.h"
17 #include "GrTypes.h" 17 #include "GrTypes.h"
18 #include "SkStrokeRec.h" 18 #include "SkStrokeRec.h"
19 #include "SkTemplates.h" 19 #include "SkTemplates.h"
20 20
21 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) 21 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
22 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) 22 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X)
23 23
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 bool GrGLGpu::fullReadPixelsIsFasterThanPartial() const { 235 bool GrGLGpu::fullReadPixelsIsFasterThanPartial() const {
236 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL); 236 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL);
237 } 237 }
238 238
239 void GrGLGpu::onResetContext(uint32_t resetBits) { 239 void GrGLGpu::onResetContext(uint32_t resetBits) {
240 // we don't use the zb at all 240 // we don't use the zb at all
241 if (resetBits & kMisc_GrGLBackendState) { 241 if (resetBits & kMisc_GrGLBackendState) {
242 GL_CALL(Disable(GR_GL_DEPTH_TEST)); 242 GL_CALL(Disable(GR_GL_DEPTH_TEST));
243 GL_CALL(DepthMask(GR_GL_FALSE)); 243 GL_CALL(DepthMask(GR_GL_FALSE));
244 244
245 fHWDrawFace = GrDrawState::kInvalid_DrawFace; 245 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace;
246 fHWDitherEnabled = kUnknown_TriState; 246 fHWDitherEnabled = kUnknown_TriState;
247 247
248 if (kGL_GrGLStandard == this->glStandard()) { 248 if (kGL_GrGLStandard == this->glStandard()) {
249 // Desktop-only state that we never change 249 // Desktop-only state that we never change
250 if (!this->glCaps().isCoreProfile()) { 250 if (!this->glCaps().isCoreProfile()) {
251 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); 251 GL_CALL(Disable(GR_GL_POINT_SMOOTH));
252 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); 252 GL_CALL(Disable(GR_GL_LINE_SMOOTH));
253 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); 253 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
254 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); 254 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
255 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); 255 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 return; 1331 return;
1332 } 1332 }
1333 } 1333 }
1334 1334
1335 // See fall through note above 1335 // See fall through note above
1336 this->disableScissor(); 1336 this->disableScissor();
1337 } 1337 }
1338 1338
1339 bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) { 1339 bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) {
1340 GrXferProcessor::BlendInfo blendInfo; 1340 GrXferProcessor::BlendInfo blendInfo;
1341 const GrOptDrawState& optState = *args.fOptState; 1341 const GrPipeline& pipeline = *args.fPipeline;
1342 args.fOptState->getXferProcessor()->getBlendInfo(&blendInfo); 1342 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo);
1343 1343
1344 this->flushDither(optState.isDitherState()); 1344 this->flushDither(pipeline.isDitherState());
1345 this->flushColorWrite(blendInfo.fWriteColor); 1345 this->flushColorWrite(blendInfo.fWriteColor);
1346 this->flushDrawFace(optState.getDrawFace()); 1346 this->flushDrawFace(pipeline.getDrawFace());
1347 1347
1348 fCurrentProgram.reset(fProgramCache->getProgram(args)); 1348 fCurrentProgram.reset(fProgramCache->getProgram(args));
1349 if (NULL == fCurrentProgram.get()) { 1349 if (NULL == fCurrentProgram.get()) {
1350 SkDEBUGFAIL("Failed to create program!"); 1350 SkDEBUGFAIL("Failed to create program!");
1351 return false; 1351 return false;
1352 } 1352 }
1353 1353
1354 fCurrentProgram.get()->ref(); 1354 fCurrentProgram.get()->ref();
1355 1355
1356 GrGLuint programID = fCurrentProgram->programID(); 1356 GrGLuint programID = fCurrentProgram->programID();
1357 if (fHWProgramID != programID) { 1357 if (fHWProgramID != programID) {
1358 GL_CALL(UseProgram(programID)); 1358 GL_CALL(UseProgram(programID));
1359 fHWProgramID = programID; 1359 fHWProgramID = programID;
1360 } 1360 }
1361 1361
1362 if (blendInfo.fWriteColor) { 1362 if (blendInfo.fWriteColor) {
1363 this->flushBlend(blendInfo); 1363 this->flushBlend(blendInfo);
1364 } 1364 }
1365 1365
1366 fCurrentProgram->setData(*args.fPrimitiveProcessor, optState, *args.fBatchTr acker); 1366 fCurrentProgram->setData(*args.fPrimitiveProcessor, pipeline, *args.fBatchTr acker);
1367 1367
1368 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTa rget()); 1368 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
1369 this->flushStencil(optState.getStencil()); 1369 this->flushStencil(pipeline.getStencil());
1370 this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->or igin()); 1370 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin());
1371 this->flushHWAAState(glRT, optState.isHWAntialiasState(), isLineDraw); 1371 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw);
1372 1372
1373 // This must come after textures are flushed because a texture may need 1373 // This must come after textures are flushed because a texture may need
1374 // to be msaa-resolved (which will modify bound FBO state). 1374 // to be msaa-resolved (which will modify bound FBO state).
1375 this->flushRenderTarget(glRT, NULL); 1375 this->flushRenderTarget(glRT, NULL);
1376 1376
1377 return true; 1377 return true;
1378 } 1378 }
1379 1379
1380 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, 1380 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
1381 const GrDrawTarget::DrawInfo& info, 1381 const GrDrawTarget::DrawInfo& info,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 stride, 1425 stride,
1426 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o ffset)); 1426 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o ffset));
1427 offset += attrib.fOffset; 1427 offset += attrib.fOffset;
1428 } 1428 }
1429 attribState->disableUnusedArrays(this, usedAttribArraysMask); 1429 attribState->disableUnusedArrays(this, usedAttribArraysMask);
1430 } 1430 }
1431 } 1431 }
1432 1432
1433 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, 1433 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc,
1434 const GrPrimitiveProcessor& primProc, 1434 const GrPrimitiveProcessor& primProc,
1435 const GrOptDrawState& optState, 1435 const GrPipeline& pipeline,
1436 const GrProgramDesc::DescInfo& descInfo, 1436 const GrProgramDesc::DescInfo& descInfo,
1437 const GrBatchTracker& batchTracker) const { 1437 const GrBatchTracker& batchTracker) const {
1438 if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, this, 1438 if (!GrGLProgramDescBuilder::Build(desc, primProc, pipeline, descInfo, this,
1439 batchTracker)) { 1439 batchTracker)) {
1440 SkDEBUGFAIL("Failed to generate GL program descriptor"); 1440 SkDEBUGFAIL("Failed to generate GL program descriptor");
1441 } 1441 }
1442 } 1442 }
1443 1443
1444 void GrGLGpu::disableScissor() { 1444 void GrGLGpu::disableScissor() {
1445 if (kNo_TriState != fHWScissorSettings.fEnabled) { 1445 if (kNo_TriState != fHWScissorSettings.fEnabled) {
1446 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); 1446 GL_CALL(Disable(GR_GL_SCISSOR_TEST));
1447 fHWScissorSettings.fEnabled = kNo_TriState; 1447 fHWScissorSettings.fEnabled = kNo_TriState;
1448 return; 1448 return;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 #elif defined(SK_BUILD_FOR_WIN32) 1857 #elif defined(SK_BUILD_FOR_WIN32)
1858 SwapBuf(); 1858 SwapBuf();
1859 int set_a_break_pt_here = 9; 1859 int set_a_break_pt_here = 9;
1860 SwapBuf(); 1860 SwapBuf();
1861 #endif 1861 #endif
1862 #endif 1862 #endif
1863 } 1863 }
1864 1864
1865 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { 1865 void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) {
1866 this->flushColorWrite(false); 1866 this->flushColorWrite(false);
1867 this->flushDrawFace(GrDrawState::kBoth_DrawFace); 1867 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
1868 1868
1869 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget); 1869 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget);
1870 SkISize size = SkISize::Make(rt->width(), rt->height()); 1870 SkISize size = SkISize::Make(rt->width(), rt->height());
1871 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o rigin()); 1871 this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->o rigin());
1872 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); 1872 this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin());
1873 this->flushHWAAState(rt, state.fUseHWAA, false); 1873 this->flushHWAAState(rt, state.fUseHWAA, false);
1874 this->flushRenderTarget(rt, NULL); 1874 this->flushRenderTarget(rt, NULL);
1875 1875
1876 fPathRendering->stencilPath(path, *state.fStencil); 1876 fPathRendering->stencilPath(path, *state.fStencil);
1877 } 1877 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 fHWWriteToColor = kNo_TriState; 2227 fHWWriteToColor = kNo_TriState;
2228 } 2228 }
2229 } else { 2229 } else {
2230 if (kYes_TriState != fHWWriteToColor) { 2230 if (kYes_TriState != fHWWriteToColor) {
2231 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); 2231 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
2232 fHWWriteToColor = kYes_TriState; 2232 fHWWriteToColor = kYes_TriState;
2233 } 2233 }
2234 } 2234 }
2235 } 2235 }
2236 2236
2237 void GrGLGpu::flushDrawFace(GrDrawState::DrawFace face) { 2237 void GrGLGpu::flushDrawFace(GrPipelineBuilder::DrawFace face) {
2238 if (fHWDrawFace != face) { 2238 if (fHWDrawFace != face) {
2239 switch (face) { 2239 switch (face) {
2240 case GrDrawState::kCCW_DrawFace: 2240 case GrPipelineBuilder::kCCW_DrawFace:
2241 GL_CALL(Enable(GR_GL_CULL_FACE)); 2241 GL_CALL(Enable(GR_GL_CULL_FACE));
2242 GL_CALL(CullFace(GR_GL_BACK)); 2242 GL_CALL(CullFace(GR_GL_BACK));
2243 break; 2243 break;
2244 case GrDrawState::kCW_DrawFace: 2244 case GrPipelineBuilder::kCW_DrawFace:
2245 GL_CALL(Enable(GR_GL_CULL_FACE)); 2245 GL_CALL(Enable(GR_GL_CULL_FACE));
2246 GL_CALL(CullFace(GR_GL_FRONT)); 2246 GL_CALL(CullFace(GR_GL_FRONT));
2247 break; 2247 break;
2248 case GrDrawState::kBoth_DrawFace: 2248 case GrPipelineBuilder::kBoth_DrawFace:
2249 GL_CALL(Disable(GR_GL_CULL_FACE)); 2249 GL_CALL(Disable(GR_GL_CULL_FACE));
2250 break; 2250 break;
2251 default: 2251 default:
2252 SkFAIL("Unknown draw face."); 2252 SkFAIL("Unknown draw face.");
2253 } 2253 }
2254 fHWDrawFace = face; 2254 fHWDrawFace = face;
2255 } 2255 }
2256 } 2256 }
2257 2257
2258 bool GrGLGpu::configToGLFormats(GrPixelConfig config, 2258 bool GrGLGpu::configToGLFormats(GrPixelConfig config,
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2743 this->setVertexArrayID(gpu, 0); 2743 this->setVertexArrayID(gpu, 0);
2744 } 2744 }
2745 int attrCount = gpu->glCaps().maxVertexAttributes(); 2745 int attrCount = gpu->glCaps().maxVertexAttributes();
2746 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2746 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2747 fDefaultVertexArrayAttribState.resize(attrCount); 2747 fDefaultVertexArrayAttribState.resize(attrCount);
2748 } 2748 }
2749 attribState = &fDefaultVertexArrayAttribState; 2749 attribState = &fDefaultVertexArrayAttribState;
2750 } 2750 }
2751 return attribState; 2751 return attribState;
2752 } 2752 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLGpuProgramCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698