| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 &tempDrawInfo)) { | 358 &tempDrawInfo)) { |
| 359 return false; | 359 return false; |
| 360 } | 360 } |
| 361 | 361 |
| 362 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has
PendingIO()) { | 362 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has
PendingIO()) { |
| 363 this->flush(); | 363 this->flush(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 SkAutoTUnref<GrTexture> tempTexture; | 366 SkAutoTUnref<GrTexture> tempTexture; |
| 367 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { | 367 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
| 368 tempTexture.reset(this->textureProvider()->refScratchTexture( | 368 tempTexture.reset( |
| 369 tempDrawInfo.fTempSurfaceDesc, GrTextureProvider::kApprox_ScratchTex
Match)); | 369 this->textureProvider()->createApproxTexture(tempDrawInfo.fTempSurfa
ceDesc)); |
| 370 if (!tempTexture && GrGpu::kRequireDraw_DrawPreference == drawPreference
) { | 370 if (!tempTexture && GrGpu::kRequireDraw_DrawPreference == drawPreference
) { |
| 371 return false; | 371 return false; |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 | 374 |
| 375 // temp buffer for doing sw premul conversion, if needed. | 375 // temp buffer for doing sw premul conversion, if needed. |
| 376 SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); | 376 SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); |
| 377 if (tempTexture) { | 377 if (tempTexture) { |
| 378 SkAutoTUnref<const GrFragmentProcessor> fp; | 378 SkAutoTUnref<const GrFragmentProcessor> fp; |
| 379 SkMatrix textureMatrix; | 379 SkMatrix textureMatrix; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 488 |
| 489 GrGpu::ReadPixelTempDrawInfo tempDrawInfo; | 489 GrGpu::ReadPixelTempDrawInfo tempDrawInfo; |
| 490 if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawP
reference, | 490 if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawP
reference, |
| 491 &tempDrawInfo)) { | 491 &tempDrawInfo)) { |
| 492 return false; | 492 return false; |
| 493 } | 493 } |
| 494 | 494 |
| 495 SkAutoTUnref<GrSurface> surfaceToRead(SkRef(src)); | 495 SkAutoTUnref<GrSurface> surfaceToRead(SkRef(src)); |
| 496 bool didTempDraw = false; | 496 bool didTempDraw = false; |
| 497 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { | 497 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
| 498 GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_Sc
ratchTexMatch; | |
| 499 if (tempDrawInfo.fUseExactScratch) { | 498 if (tempDrawInfo.fUseExactScratch) { |
| 500 // We only respect this when the entire src is being read. Otherwise
we can trigger too | 499 // We only respect this when the entire src is being read. Otherwise
we can trigger too |
| 501 // many odd ball texture sizes and trash the cache. | 500 // many odd ball texture sizes and trash the cache. |
| 502 if (width == src->width() && height == src->height()) { | 501 if (width != src->width() || height != src->height()) { |
| 503 match = GrTextureProvider::kExact_ScratchTexMatch; | 502 tempDrawInfo.fUseExactScratch = false; |
| 504 } | 503 } |
| 505 } | 504 } |
| 506 SkAutoTUnref<GrTexture> temp; | 505 SkAutoTUnref<GrTexture> temp; |
| 507 temp.reset(this->textureProvider()->refScratchTexture(tempDrawInfo.fTemp
SurfaceDesc, | 506 if (tempDrawInfo.fUseExactScratch) { |
| 508 match)); | 507 temp.reset(this->textureProvider()->createTexture(tempDrawInfo.fTemp
SurfaceDesc, true)); |
| 508 } else { |
| 509 temp.reset(this->textureProvider()->createApproxTexture(tempDrawInfo
.fTempSurfaceDesc)); |
| 510 } |
| 509 if (temp) { | 511 if (temp) { |
| 510 SkMatrix textureMatrix; | 512 SkMatrix textureMatrix; |
| 511 textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); | 513 textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
| 512 textureMatrix.postIDiv(src->width(), src->height()); | 514 textureMatrix.postIDiv(src->width(), src->height()); |
| 513 GrPaint paint; | 515 GrPaint paint; |
| 514 SkAutoTUnref<const GrFragmentProcessor> fp; | 516 SkAutoTUnref<const GrFragmentProcessor> fp; |
| 515 if (unpremul) { | 517 if (unpremul) { |
| 516 fp.reset(this->createPMToUPMEffect( | 518 fp.reset(this->createPMToUPMEffect( |
| 517 paint.getProcessorDataManager(), src->asTexture(), tempDrawI
nfo.fSwapRAndB, | 519 paint.getProcessorDataManager(), src->asTexture(), tempDrawI
nfo.fSwapRAndB, |
| 518 textureMatrix)); | 520 textureMatrix)); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 ////////////////////////////////////////////////////////////////////////////// | 754 ////////////////////////////////////////////////////////////////////////////// |
| 753 | 755 |
| 754 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { | 756 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 755 fGpu->addGpuTraceMarker(marker); | 757 fGpu->addGpuTraceMarker(marker); |
| 756 } | 758 } |
| 757 | 759 |
| 758 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 760 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 759 fGpu->removeGpuTraceMarker(marker); | 761 fGpu->removeGpuTraceMarker(marker); |
| 760 } | 762 } |
| 761 | 763 |
| OLD | NEW |