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 // Don't prefer to draw for the conversion (and thereby access a texture fro
m the cache) when |
| 351 // we've already determined that there isn't a roundtrip preserving conversi
on processor pair. |
| 352 if (applyPremulToSrc && !this->didFailPMUPMConversionTest()) { |
| 353 drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; |
| 354 } |
| 355 |
351 GrGpu::WritePixelTempDrawInfo tempDrawInfo; | 356 GrGpu::WritePixelTempDrawInfo tempDrawInfo; |
352 if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, &
drawPreference, | 357 if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, &
drawPreference, |
353 &tempDrawInfo)) { | 358 &tempDrawInfo)) { |
354 return false; | 359 return false; |
355 } | 360 } |
356 | 361 |
357 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has
PendingIO()) { | 362 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has
PendingIO()) { |
358 this->flush(); | 363 this->flush(); |
359 } | 364 } |
360 | 365 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite
()) { | 474 if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite
()) { |
470 this->flush(); | 475 this->flush(); |
471 } | 476 } |
472 | 477 |
473 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); | 478 bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); |
474 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { | 479 if (unpremul && !GrPixelConfigIs8888(dstConfig)) { |
475 // The unpremul flag is only allowed for 8888 configs. | 480 // The unpremul flag is only allowed for 8888 configs. |
476 return false; | 481 return false; |
477 } | 482 } |
478 | 483 |
479 GrGpu::DrawPreference drawPreference = unpremul ? GrGpu::kCallerPrefersDraw_
DrawPreference : | 484 GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; |
480 GrGpu::kNoDraw_DrawPrefere
nce; | 485 // Don't prefer to draw for the conversion (and thereby access a texture fro
m the cache) when |
| 486 // we've already determined that there isn't a roundtrip preserving conversi
on processor pair. |
| 487 if (unpremul && !this->didFailPMUPMConversionTest()) { |
| 488 drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; |
| 489 } |
| 490 |
481 GrGpu::ReadPixelTempDrawInfo tempDrawInfo; | 491 GrGpu::ReadPixelTempDrawInfo tempDrawInfo; |
482 if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawP
reference, | 492 if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawP
reference, |
483 &tempDrawInfo)) { | 493 &tempDrawInfo)) { |
484 return false; | 494 return false; |
485 } | 495 } |
486 | 496 |
487 SkAutoTUnref<GrRenderTarget> rtToRead(SkSafeRef(src->asRenderTarget())); | 497 SkAutoTUnref<GrRenderTarget> rtToRead(SkSafeRef(src->asRenderTarget())); |
488 bool didTempDraw = false; | 498 bool didTempDraw = false; |
489 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { | 499 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
490 GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_Sc
ratchTexMatch; | 500 GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_Sc
ratchTexMatch; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 GrConfigConversionEffect::PMConversion upmToPM = | 722 GrConfigConversionEffect::PMConversion upmToPM = |
713 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); | 723 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); |
714 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { | 724 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { |
715 return GrConfigConversionEffect::Create(procDataManager, texture, swapRA
ndB, upmToPM, | 725 return GrConfigConversionEffect::Create(procDataManager, texture, swapRA
ndB, upmToPM, |
716 matrix); | 726 matrix); |
717 } else { | 727 } else { |
718 return NULL; | 728 return NULL; |
719 } | 729 } |
720 } | 730 } |
721 | 731 |
| 732 bool GrContext::didFailPMUPMConversionTest() const { |
| 733 // The PM<->UPM tests fail or succeed together so we only need to check one. |
| 734 return fDidTestPMConversions && |
| 735 GrConfigConversionEffect::kNone_PMConversion == fPMToUPMConversion; |
| 736 } |
| 737 |
722 ////////////////////////////////////////////////////////////////////////////// | 738 ////////////////////////////////////////////////////////////////////////////// |
723 | 739 |
724 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes
) const { | 740 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes
) const { |
725 if (maxTextures) { | 741 if (maxTextures) { |
726 *maxTextures = fResourceCache->getMaxResourceCount(); | 742 *maxTextures = fResourceCache->getMaxResourceCount(); |
727 } | 743 } |
728 if (maxTextureBytes) { | 744 if (maxTextureBytes) { |
729 *maxTextureBytes = fResourceCache->getMaxResourceBytes(); | 745 *maxTextureBytes = fResourceCache->getMaxResourceBytes(); |
730 } | 746 } |
731 } | 747 } |
732 | 748 |
733 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ | 749 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ |
734 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 750 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
735 } | 751 } |
736 | 752 |
737 ////////////////////////////////////////////////////////////////////////////// | 753 ////////////////////////////////////////////////////////////////////////////// |
738 | 754 |
739 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { | 755 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { |
740 fGpu->addGpuTraceMarker(marker); | 756 fGpu->addGpuTraceMarker(marker); |
741 } | 757 } |
742 | 758 |
743 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 759 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
744 fGpu->removeGpuTraceMarker(marker); | 760 fGpu->removeGpuTraceMarker(marker); |
745 } | 761 } |
746 | 762 |
OLD | NEW |