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

Side by Side Diff: src/gpu/GrContext.cpp

Issue 1388113002: Bye bye processor data manager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove files Created 5 years, 2 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/GrClipMaskManager.cpp ('k') | src/gpu/GrPaint.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 /* 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 364
365 // temp buffer for doing sw premul conversion, if needed. 365 // temp buffer for doing sw premul conversion, if needed.
366 SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); 366 SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
367 if (tempTexture) { 367 if (tempTexture) {
368 SkAutoTUnref<const GrFragmentProcessor> fp; 368 SkAutoTUnref<const GrFragmentProcessor> fp;
369 SkMatrix textureMatrix; 369 SkMatrix textureMatrix;
370 textureMatrix.setIDiv(tempTexture->width(), tempTexture->height()); 370 textureMatrix.setIDiv(tempTexture->width(), tempTexture->height());
371 GrPaint paint; 371 GrPaint paint;
372 if (applyPremulToSrc) { 372 if (applyPremulToSrc) {
373 fp.reset(this->createUPMToPMEffect(paint.getProcessorDataManager(), tempTexture, 373 fp.reset(this->createUPMToPMEffect(tempTexture, tempDrawInfo.fSwapRA ndB,
374 tempDrawInfo.fSwapRAndB, textureM atrix)); 374 textureMatrix));
375 // If premultiplying was the only reason for the draw, fall back to a straight write. 375 // If premultiplying was the only reason for the draw, fall back to a straight write.
376 if (!fp) { 376 if (!fp) {
377 if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) { 377 if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
378 tempTexture.reset(nullptr); 378 tempTexture.reset(nullptr);
379 } 379 }
380 } else { 380 } else {
381 applyPremulToSrc = false; 381 applyPremulToSrc = false;
382 } 382 }
383 } 383 }
384 if (tempTexture) { 384 if (tempTexture) {
385 if (!fp) { 385 if (!fp) {
386 fp.reset(GrConfigConversionEffect::Create( 386 fp.reset(GrConfigConversionEffect::Create(tempTexture, tempDrawI nfo.fSwapRAndB,
387 paint.getProcessorDataManager(), tempTexture, tempDrawInfo.f SwapRAndB,
388 GrConfigConversionEffect::kNone_PMConversion, textureMatrix) ); 387 GrConfigConversionEffect::kNone_PMConversion, textureMatrix) );
389 if (!fp) { 388 if (!fp) {
390 return false; 389 return false;
391 } 390 }
392 } 391 }
393 GrRenderTarget* renderTarget = surface->asRenderTarget(); 392 GrRenderTarget* renderTarget = surface->asRenderTarget();
394 SkASSERT(renderTarget); 393 SkASSERT(renderTarget);
395 if (tempTexture->surfacePriv().hasPendingIO()) { 394 if (tempTexture->surfacePriv().hasPendingIO()) {
396 this->flush(); 395 this->flush();
397 } 396 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } else { 500 } else {
502 temp.reset(this->textureProvider()->createApproxTexture(tempDrawInfo .fTempSurfaceDesc)); 501 temp.reset(this->textureProvider()->createApproxTexture(tempDrawInfo .fTempSurfaceDesc));
503 } 502 }
504 if (temp) { 503 if (temp) {
505 SkMatrix textureMatrix; 504 SkMatrix textureMatrix;
506 textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); 505 textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
507 textureMatrix.postIDiv(src->width(), src->height()); 506 textureMatrix.postIDiv(src->width(), src->height());
508 GrPaint paint; 507 GrPaint paint;
509 SkAutoTUnref<const GrFragmentProcessor> fp; 508 SkAutoTUnref<const GrFragmentProcessor> fp;
510 if (unpremul) { 509 if (unpremul) {
511 fp.reset(this->createPMToUPMEffect( 510 fp.reset(this->createPMToUPMEffect(src->asTexture(), tempDrawInf o.fSwapRAndB,
512 paint.getProcessorDataManager(), src->asTexture(), tempDrawI nfo.fSwapRAndB,
513 textureMatrix)); 511 textureMatrix));
514 if (fp) { 512 if (fp) {
515 unpremul = false; // we no longer need to do this on CPU aft er the read back. 513 unpremul = false; // we no longer need to do this on CPU aft er the read back.
516 } else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPrefe rence) { 514 } else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPrefe rence) {
517 // We only wanted to do the draw in order to perform the unp remul so don't 515 // We only wanted to do the draw in order to perform the unp remul so don't
518 // bother. 516 // bother.
519 temp.reset(nullptr); 517 temp.reset(nullptr);
520 } 518 }
521 } 519 }
522 if (!fp && temp) { 520 if (!fp && temp) {
523 fp.reset(GrConfigConversionEffect::Create( 521 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp DrawInfo.fSwapRAndB,
524 paint.getProcessorDataManager(), src->asTexture(), tempDrawI nfo.fSwapRAndB,
525 GrConfigConversionEffect::kNone_PMConversion, textureMatrix) ); 522 GrConfigConversionEffect::kNone_PMConversion, textureMatrix) );
526 } 523 }
527 if (fp) { 524 if (fp) {
528 paint.addColorFragmentProcessor(fp); 525 paint.addColorFragmentProcessor(fp);
529 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar (height)); 526 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar (height));
530 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); 527 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
531 drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen() , paint, 528 drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen() , paint,
532 SkMatrix::I(), rect, nullptr); 529 SkMatrix::I(), rect, nullptr);
533 surfaceToRead.reset(SkRef(temp.get())); 530 surfaceToRead.reset(SkRef(temp.get()));
534 left = 0; 531 left = 0;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 void GrContext::testPMConversionsIfNecessary(uint32_t flags) { 687 void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
691 if (SkToBool(kUnpremul_PixelOpsFlag & flags)) { 688 if (SkToBool(kUnpremul_PixelOpsFlag & flags)) {
692 SkAutoMutexAcquire ama(fTestPMConversionsMutex); 689 SkAutoMutexAcquire ama(fTestPMConversionsMutex);
693 if (!fDidTestPMConversions) { 690 if (!fDidTestPMConversions) {
694 test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion); 691 test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
695 fDidTestPMConversions = true; 692 fDidTestPMConversions = true;
696 } 693 }
697 } 694 }
698 } 695 }
699 696
700 const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrProcessorDataManager * procDataManager, 697 const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
701 GrTexture* texture,
702 bool swapRAndB, 698 bool swapRAndB,
703 const SkMatrix& matrix ) const { 699 const SkMatrix& matrix ) const {
704 // We should have already called this->testPMConversionsIfNecessary(). 700 // We should have already called this->testPMConversionsIfNecessary().
705 SkASSERT(fDidTestPMConversions); 701 SkASSERT(fDidTestPMConversions);
706 GrConfigConversionEffect::PMConversion pmToUPM = 702 GrConfigConversionEffect::PMConversion pmToUPM =
707 static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion); 703 static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
708 if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) { 704 if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
709 return GrConfigConversionEffect::Create(procDataManager, texture, swapRA ndB, pmToUPM, 705 return GrConfigConversionEffect::Create(texture, swapRAndB, pmToUPM, mat rix);
710 matrix);
711 } else { 706 } else {
712 return nullptr; 707 return nullptr;
713 } 708 }
714 } 709 }
715 710
716 const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrProcessorDataManager * procDataManager, 711 const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
717 GrTexture* texture,
718 bool swapRAndB, 712 bool swapRAndB,
719 const SkMatrix& matrix ) const { 713 const SkMatrix& matrix ) const {
720 // We should have already called this->testPMConversionsIfNecessary(). 714 // We should have already called this->testPMConversionsIfNecessary().
721 SkASSERT(fDidTestPMConversions); 715 SkASSERT(fDidTestPMConversions);
722 GrConfigConversionEffect::PMConversion upmToPM = 716 GrConfigConversionEffect::PMConversion upmToPM =
723 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); 717 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
724 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { 718 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
725 return GrConfigConversionEffect::Create(procDataManager, texture, swapRA ndB, upmToPM, 719 return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM, mat rix);
726 matrix);
727 } else { 720 } else {
728 return nullptr; 721 return nullptr;
729 } 722 }
730 } 723 }
731 724
732 bool GrContext::didFailPMUPMConversionTest() const { 725 bool GrContext::didFailPMUPMConversionTest() const {
733 // We should have already called this->testPMConversionsIfNecessary(). 726 // We should have already called this->testPMConversionsIfNecessary().
734 SkASSERT(fDidTestPMConversions); 727 SkASSERT(fDidTestPMConversions);
735 // The PM<->UPM tests fail or succeed together so we only need to check one. 728 // The PM<->UPM tests fail or succeed together so we only need to check one.
736 return GrConfigConversionEffect::kNone_PMConversion == fPMToUPMConversion; 729 return GrConfigConversionEffect::kNone_PMConversion == fPMToUPMConversion;
(...skipping 12 matching lines...) Expand all
749 742
750 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { 743 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) {
751 fResourceCache->setLimits(maxTextures, maxTextureBytes); 744 fResourceCache->setLimits(maxTextures, maxTextureBytes);
752 } 745 }
753 746
754 ////////////////////////////////////////////////////////////////////////////// 747 //////////////////////////////////////////////////////////////////////////////
755 748
756 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 749 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
757 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 750 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
758 } 751 }
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698