Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 | 10 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 return false; | 338 return false; |
| 339 } | 339 } |
| 340 | 340 |
| 341 bool applyPremulToSrc = false; | 341 bool applyPremulToSrc = false; |
| 342 if (kUnpremul_PixelOpsFlag & pixelOpsFlags) { | 342 if (kUnpremul_PixelOpsFlag & pixelOpsFlags) { |
| 343 if (!GrPixelConfigIs8888(srcConfig)) { | 343 if (!GrPixelConfigIs8888(srcConfig)) { |
| 344 return false; | 344 return false; |
| 345 } | 345 } |
| 346 applyPremulToSrc = true; | 346 applyPremulToSrc = true; |
| 347 } | 347 } |
| 348 GrGpu::DrawPreference drawPreference = applyPremulToSrc ? | 348 |
| 349 GrGpu::kCallerPrefersDraw_DrawPrefer ence : | 349 GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; |
| 350 GrGpu::kNoDraw_DrawPreference; | 350 if (applyPremulToSrc && !this->didFailPMUPMConversionTest()) { |
| 351 drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; | |
| 352 } | |
| 353 | |
| 351 GrGpu::WritePixelTempDrawInfo tempDrawInfo; | 354 GrGpu::WritePixelTempDrawInfo tempDrawInfo; |
| 352 if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, & drawPreference, | 355 if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, & drawPreference, |
| 353 &tempDrawInfo)) { | 356 &tempDrawInfo)) { |
| 354 return false; | 357 return false; |
| 355 } | 358 } |
| 356 | 359 |
| 357 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has PendingIO()) { | 360 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has PendingIO()) { |
| 358 this->flush(); | 361 this->flush(); |
| 359 } | 362 } |
| 360 | 363 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite ()) { | 472 if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite ()) { |
| 470 this->flush(); | 473 this->flush(); |
| 471 } | 474 } |
| 472 | 475 |
| 473 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); | 476 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); |
| 474 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { | 477 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { |
| 475 // The unpremul flag is only allowed for 8888 configs. | 478 // The unpremul flag is only allowed for 8888 configs. |
| 476 return false; | 479 return false; |
| 477 } | 480 } |
| 478 | 481 |
| 479 GrGpu::DrawPreference drawPreference = unpremul ? GrGpu::kCallerPrefersDraw_ DrawPreference : | 482 GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; |
| 480 GrGpu::kNoDraw_DrawPrefere nce; | 483 if (unpremul && !this->didFailPMUPMConversionTest()) { |
| 484 drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; | |
| 485 } | |
| 486 | |
| 481 GrGpu::ReadPixelTempDrawInfo tempDrawInfo; | 487 GrGpu::ReadPixelTempDrawInfo tempDrawInfo; |
| 482 if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawP reference, | 488 if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawP reference, |
| 483 &tempDrawInfo)) { | 489 &tempDrawInfo)) { |
| 484 return false; | 490 return false; |
| 485 } | 491 } |
| 486 | 492 |
| 487 GrRenderTarget* rtToRead = src->asRenderTarget(); | 493 GrRenderTarget* rtToRead = src->asRenderTarget(); |
| 488 bool didTempDraw = false; | 494 bool didTempDraw = false; |
| 489 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { | 495 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
| 490 GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_Sc ratchTexMatch; | 496 GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_Sc ratchTexMatch; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 GrConfigConversionEffect::PMConversion upmToPM = | 717 GrConfigConversionEffect::PMConversion upmToPM = |
| 712 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); | 718 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); |
| 713 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { | 719 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { |
| 714 return GrConfigConversionEffect::Create(procDataManager, texture, swapRA ndB, upmToPM, | 720 return GrConfigConversionEffect::Create(procDataManager, texture, swapRA ndB, upmToPM, |
| 715 matrix); | 721 matrix); |
| 716 } else { | 722 } else { |
| 717 return NULL; | 723 return NULL; |
| 718 } | 724 } |
| 719 } | 725 } |
| 720 | 726 |
| 727 bool GrContext::didFailPMUPMConversionTest() const { | |
|
robertphillips
2015/07/29 12:35:05
// The PM<->UPM tests fail or succeed together so
bsalomon
2015/07/29 13:01:34
Done.
| |
| 728 return fDidTestPMConversions && | |
| 729 GrConfigConversionEffect::kNone_PMConversion == fPMToUPMConversion; | |
| 730 } | |
| 731 | |
| 721 ////////////////////////////////////////////////////////////////////////////// | 732 ////////////////////////////////////////////////////////////////////////////// |
| 722 | 733 |
| 723 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes ) const { | 734 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes ) const { |
| 724 if (maxTextures) { | 735 if (maxTextures) { |
| 725 *maxTextures = fResourceCache->getMaxResourceCount(); | 736 *maxTextures = fResourceCache->getMaxResourceCount(); |
| 726 } | 737 } |
| 727 if (maxTextureBytes) { | 738 if (maxTextureBytes) { |
| 728 *maxTextureBytes = fResourceCache->getMaxResourceBytes(); | 739 *maxTextureBytes = fResourceCache->getMaxResourceBytes(); |
| 729 } | 740 } |
| 730 } | 741 } |
| 731 | 742 |
| 732 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { | 743 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { |
| 733 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 744 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 734 } | 745 } |
| 735 | 746 |
| 736 ////////////////////////////////////////////////////////////////////////////// | 747 ////////////////////////////////////////////////////////////////////////////// |
| 737 | 748 |
| 738 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { | 749 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 739 fGpu->addGpuTraceMarker(marker); | 750 fGpu->addGpuTraceMarker(marker); |
| 740 } | 751 } |
| 741 | 752 |
| 742 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 753 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 743 fGpu->removeGpuTraceMarker(marker); | 754 fGpu->removeGpuTraceMarker(marker); |
| 744 } | 755 } |
| 745 | 756 |
| OLD | NEW |