OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "GrGpu.h" | 9 #include "GrGpu.h" |
10 | 10 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 if (GrRenderTarget* target = surface->asRenderTarget()) { | 435 if (GrRenderTarget* target = surface->asRenderTarget()) { |
436 target->flagAsNeedingResolve(bounds); | 436 target->flagAsNeedingResolve(bounds); |
437 } | 437 } |
438 GrTexture* texture = surface->asTexture(); | 438 GrTexture* texture = surface->asTexture(); |
439 if (texture && 1 == mipLevels) { | 439 if (texture && 1 == mipLevels) { |
440 texture->texturePriv().dirtyMipMaps(true); | 440 texture->texturePriv().dirtyMipMaps(true); |
441 } | 441 } |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 const GrGpu::MultisampleSpecs& GrGpu::getMultisampleSpecs(GrRenderTarget* rt, | 445 const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(GrRenderTarget* rt, |
446 const GrStencilSetting
s& stencil) { | 446 const GrStencilSetti
ngs& stencil) { |
447 SkASSERT(rt->desc().fSampleCnt > 1); | 447 SkASSERT(rt->desc().fSampleCnt > 1); |
448 | 448 |
449 #ifndef SK_DEBUG | |
450 // In debug mode we query the multisample info every time to verify the cach
ing is correct. | |
451 if (uint8_t id = rt->renderTargetPriv().accessMultisampleSpecsID()) { | |
452 SkASSERT(id > 0 && id < fMultisampleSpecs.count()); | |
453 return fMultisampleSpecs[id]; | |
454 } | |
455 #endif | |
456 | |
457 int effectiveSampleCnt; | 449 int effectiveSampleCnt; |
458 SkSTArray<16, SkPoint, true> pattern; | 450 SkSTArray<16, SkPoint, true> pattern; |
459 this->onGetMultisampleSpecs(rt, stencil, &effectiveSampleCnt, &pattern); | 451 this->onQueryMultisampleSpecs(rt, stencil, &effectiveSampleCnt, &pattern); |
460 SkASSERT(effectiveSampleCnt >= rt->desc().fSampleCnt); | 452 SkASSERT(effectiveSampleCnt >= rt->desc().fSampleCnt); |
461 | 453 |
462 uint8_t id; | 454 uint8_t id; |
463 if (this->caps()->sampleLocationsSupport()) { | 455 if (this->caps()->sampleLocationsSupport()) { |
464 SkASSERT(pattern.count() == effectiveSampleCnt); | 456 SkASSERT(pattern.count() == effectiveSampleCnt); |
465 const auto& insertResult = fMultisampleSpecsIdMap.insert( | 457 const auto& insertResult = fMultisampleSpecsIdMap.insert( |
466 MultisampleSpecsIdMap::value_type(pattern, SkTMin(fMultisampleSpecs.
count(), 255))); | 458 MultisampleSpecsIdMap::value_type(pattern, SkTMin(fMultisampleSpecs.
count(), 255))); |
467 id = insertResult.first->second; | 459 id = insertResult.first->second; |
468 if (insertResult.second) { | 460 if (insertResult.second) { |
469 // This means the insert did not find the pattern in the map already
, and therefore an | 461 // This means the insert did not find the pattern in the map already
, and therefore an |
470 // actual insertion took place. (We don't expect to see many unique
sample patterns.) | 462 // actual insertion took place. (We don't expect to see many unique
sample patterns.) |
471 const SkPoint* sampleLocations = insertResult.first->first.begin(); | 463 const SkPoint* sampleLocations = insertResult.first->first.begin(); |
472 SkASSERT(id == fMultisampleSpecs.count()); | 464 SkASSERT(id == fMultisampleSpecs.count()); |
473 fMultisampleSpecs.emplace_back(id, effectiveSampleCnt, sampleLocatio
ns); | 465 fMultisampleSpecs.emplace_back(id, effectiveSampleCnt, sampleLocatio
ns); |
474 } | 466 } |
475 } else { | 467 } else { |
476 id = effectiveSampleCnt; | 468 id = effectiveSampleCnt; |
477 for (int i = fMultisampleSpecs.count(); i <= id; ++i) { | 469 for (int i = fMultisampleSpecs.count(); i <= id; ++i) { |
478 fMultisampleSpecs.emplace_back(i, i, nullptr); | 470 fMultisampleSpecs.emplace_back(i, i, nullptr); |
479 } | 471 } |
480 } | 472 } |
481 SkASSERT(id > 0); | 473 SkASSERT(id > 0); |
482 SkASSERT(!rt->renderTargetPriv().accessMultisampleSpecsID() || | |
483 rt->renderTargetPriv().accessMultisampleSpecsID() == id); | |
484 | 474 |
485 rt->renderTargetPriv().accessMultisampleSpecsID() = id; | |
486 return fMultisampleSpecs[id]; | 475 return fMultisampleSpecs[id]; |
487 } | 476 } |
488 | 477 |
489 bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a, | 478 bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a, |
490 const SamplePattern& b) const { | 479 const SamplePattern& b) const { |
491 if (a.count() != b.count()) { | 480 if (a.count() != b.count()) { |
492 return a.count() < b.count(); | 481 return a.count() < b.count(); |
493 } | 482 } |
494 for (int i = 0; i < a.count(); ++i) { | 483 for (int i = 0; i < a.count(); ++i) { |
495 // This doesn't have geometric meaning. We just need to define an orderi
ng for std::map. | 484 // This doesn't have geometric meaning. We just need to define an orderi
ng for std::map. |
496 if (a[i].x() != b[i].x()) { | 485 if (a[i].x() != b[i].x()) { |
497 return a[i].x() < b[i].x(); | 486 return a[i].x() < b[i].x(); |
498 } | 487 } |
499 if (a[i].y() != b[i].y()) { | 488 if (a[i].y() != b[i].y()) { |
500 return a[i].y() < b[i].y(); | 489 return a[i].y() < b[i].y(); |
501 } | 490 } |
502 } | 491 } |
503 return false; // Equal. | 492 return false; // Equal. |
504 } | 493 } |
OLD | NEW |