| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
| 10 #include "GrGLContext.h" | 10 #include "GrGLContext.h" |
| 11 #include "SkTSearch.h" | 11 #include "SkTSearch.h" |
| 12 #include "SkTSort.h" |
| 12 | 13 |
| 13 SK_DEFINE_INST_COUNT(GrGLCaps) | 14 SK_DEFINE_INST_COUNT(GrGLCaps) |
| 14 | 15 |
| 15 GrGLCaps::GrGLCaps() { | 16 GrGLCaps::GrGLCaps() { |
| 16 this->reset(); | 17 this->reset(); |
| 17 } | 18 } |
| 18 | 19 |
| 19 void GrGLCaps::reset() { | 20 void GrGLCaps::reset() { |
| 20 INHERITED::reset(); | 21 INHERITED::reset(); |
| 21 | 22 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 &otherFormat); | 329 &otherFormat); |
| 329 | 330 |
| 330 GR_GL_GetIntegerv(intf, | 331 GR_GL_GetIntegerv(intf, |
| 331 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, | 332 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 332 &otherType); | 333 &otherType); |
| 333 | 334 |
| 334 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; | 335 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
| 335 } | 336 } |
| 336 | 337 |
| 337 namespace { | 338 namespace { |
| 338 int coverage_mode_compare(const GrGLCaps::MSAACoverageMode* left, | 339 bool cov_mode_less(const GrGLCaps::MSAACoverageMode& left, |
| 339 const GrGLCaps::MSAACoverageMode* right) { | 340 const GrGLCaps::MSAACoverageMode& right) { |
| 340 if (left->fCoverageSampleCnt < right->fCoverageSampleCnt) { | 341 if (left.fCoverageSampleCnt < right.fCoverageSampleCnt) { |
| 341 return -1; | 342 return true; |
| 342 } else if (right->fCoverageSampleCnt < left->fCoverageSampleCnt) { | 343 } else if (right.fCoverageSampleCnt < left.fCoverageSampleCnt) { |
| 343 return 1; | 344 return false; |
| 344 } else if (left->fColorSampleCnt < right->fColorSampleCnt) { | 345 } else if (left.fColorSampleCnt < right.fColorSampleCnt) { |
| 345 return -1; | 346 return true; |
| 346 } else if (right->fColorSampleCnt < left->fColorSampleCnt) { | |
| 347 return 1; | |
| 348 } | 347 } |
| 349 return 0; | 348 return false; |
| 350 } | 349 } |
| 351 } | 350 } |
| 352 | 351 |
| 353 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { | 352 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { |
| 354 | 353 |
| 355 fMSFBOType = kNone_MSFBOType; | 354 fMSFBOType = kNone_MSFBOType; |
| 356 if (kDesktop_GrGLBinding != ctxInfo.binding()) { | 355 if (kDesktop_GrGLBinding != ctxInfo.binding()) { |
| 357 if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { | 356 if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { |
| 358 // chrome's extension is equivalent to the EXT msaa | 357 // chrome's extension is equivalent to the EXT msaa |
| 359 // and fbo_blit extensions. | 358 // and fbo_blit extensions. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 382 GrGLint count; | 381 GrGLint count; |
| 383 GR_GL_GetIntegerv(gli, | 382 GR_GL_GetIntegerv(gli, |
| 384 GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES, | 383 GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES, |
| 385 &count); | 384 &count); |
| 386 fMSAACoverageModes.setCount(count); | 385 fMSAACoverageModes.setCount(count); |
| 387 GR_GL_GetIntegerv(gli, | 386 GR_GL_GetIntegerv(gli, |
| 388 GR_GL_MULTISAMPLE_COVERAGE_MODES, | 387 GR_GL_MULTISAMPLE_COVERAGE_MODES, |
| 389 (int*)&fMSAACoverageModes[0]); | 388 (int*)&fMSAACoverageModes[0]); |
| 390 // The NV driver seems to return the modes already sorted but the | 389 // The NV driver seems to return the modes already sorted but the |
| 391 // spec doesn't require this. So we sort. | 390 // spec doesn't require this. So we sort. |
| 392 qsort(&fMSAACoverageModes[0], | 391 typedef SkTLessFunctionToFunctorAdaptor<MSAACoverageMode, cov_mode_l
ess> SortFunctor; |
| 393 count, | 392 SortFunctor sortFunctor; |
| 394 sizeof(MSAACoverageMode), | 393 SkTQSort<MSAACoverageMode, SortFunctor>(fMSAACoverageModes.begin(), |
| 395 SkCastForQSort(coverage_mode_compare)); | 394 fMSAACoverageModes.end() - 1
, |
| 395 sortFunctor); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampl
eCount) const { | 400 const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampl
eCount) const { |
| 401 static const MSAACoverageMode kNoneMode = {0, 0}; | 401 static const MSAACoverageMode kNoneMode = {0, 0}; |
| 402 if (0 == fMSAACoverageModes.count()) { | 402 if (0 == fMSAACoverageModes.count()) { |
| 403 return kNoneMode; | 403 return kNoneMode; |
| 404 } else { | 404 } else { |
| 405 GrAssert(kNone_CoverageAAType != fCoverageAAType); | 405 GrAssert(kNone_CoverageAAType != fCoverageAAType); |
| 406 int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt; | 406 int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt; |
| 407 desiredSampleCount = GrMin(desiredSampleCount, max); | 407 desiredSampleCount = GrMin(desiredSampleCount, max); |
| 408 MSAACoverageMode desiredMode = {desiredSampleCount, 0}; | 408 MSAACoverageMode desiredMode = {desiredSampleCount, 0}; |
| 409 int idx = SkTSearch<MSAACoverageMode>(&fMSAACoverageModes[0], | 409 int idx = SkTSearch<const MSAACoverageMode, cov_mode_less>(&fMSAACoverag
eModes[0], |
| 410 fMSAACoverageModes.count(), | 410 fMSAACoverage
Modes.count(), |
| 411 desiredMode, | 411 desiredMode, |
| 412 sizeof(MSAACoverageMode), | 412 sizeof(MSAACo
verageMode)); |
| 413 &coverage_mode_compare); | |
| 414 if (idx < 0) { | 413 if (idx < 0) { |
| 415 idx = ~idx; | 414 idx = ~idx; |
| 416 } | 415 } |
| 417 GrAssert(idx >= 0 && idx < fMSAACoverageModes.count()); | 416 GrAssert(idx >= 0 && idx < fMSAACoverageModes.count()); |
| 418 return fMSAACoverageModes[idx]; | 417 return fMSAACoverageModes[idx]; |
| 419 } | 418 } |
| 420 } | 419 } |
| 421 | 420 |
| 422 namespace { | 421 namespace { |
| 423 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; | 422 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 578 GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
| 580 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 579 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
| 581 GrPrintf("Fragment coord conventions support: %s\n", | 580 GrPrintf("Fragment coord conventions support: %s\n", |
| 582 (fFragCoordsConventionSupport ? "YES": "NO")); | 581 (fFragCoordsConventionSupport ? "YES": "NO")); |
| 583 GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "
YES": "NO")); | 582 GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "
YES": "NO")); |
| 584 GrPrintf("Use non-VBO for dynamic data: %s\n", | 583 GrPrintf("Use non-VBO for dynamic data: %s\n", |
| 585 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 584 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 586 GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); | 585 GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
| 587 GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "
NO")); | 586 GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "
NO")); |
| 588 } | 587 } |
| OLD | NEW |