| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "GrContext.h" | 8 #include "GrContext.h" |
| 9 #include "GrContextOptions.h" | 9 #include "GrContextOptions.h" |
| 10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 buffer = tmpPixels.get(); | 355 buffer = tmpPixels.get(); |
| 356 applyPremulToSrc = false; | 356 applyPremulToSrc = false; |
| 357 } | 357 } |
| 358 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, | 358 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, |
| 359 tempDrawInfo.fWriteConfig, buffer, | 359 tempDrawInfo.fWriteConfig, buffer, |
| 360 rowBytes)) { | 360 rowBytes)) { |
| 361 return false; | 361 return false; |
| 362 } | 362 } |
| 363 SkMatrix matrix; | 363 SkMatrix matrix; |
| 364 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); | 364 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
| 365 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarg
et)); | 365 sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(renderT
arget))); |
| 366 if (!drawContext) { | 366 if (!drawContext) { |
| 367 return false; | 367 return false; |
| 368 } | 368 } |
| 369 // SRGBTODO: AllowSRGBInputs? (We could force it on here, so we don'
t need the | 369 // SRGBTODO: AllowSRGBInputs? (We could force it on here, so we don'
t need the |
| 370 // per-texture override in config conversion effect?) | 370 // per-texture override in config conversion effect?) |
| 371 GrPaint paint; | 371 GrPaint paint; |
| 372 paint.addColorFragmentProcessor(fp); | 372 paint.addColorFragmentProcessor(fp); |
| 373 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 373 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 374 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei
ght)); | 374 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei
ght)); |
| 375 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp
tr); | 375 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp
tr); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp
DrawInfo.fSwizzle, | 477 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp
DrawInfo.fSwizzle, |
| 478 GrConfigConversionEffect::kNone_PMConversion, textureMatrix)
); | 478 GrConfigConversionEffect::kNone_PMConversion, textureMatrix)
); |
| 479 } | 479 } |
| 480 if (fp) { | 480 if (fp) { |
| 481 // SRGBTODO: AllowSRGBInputs? (We could force it on here, so we
don't need the | 481 // SRGBTODO: AllowSRGBInputs? (We could force it on here, so we
don't need the |
| 482 // per-texture override in config conversion effect?) | 482 // per-texture override in config conversion effect?) |
| 483 GrPaint paint; | 483 GrPaint paint; |
| 484 paint.addColorFragmentProcessor(fp); | 484 paint.addColorFragmentProcessor(fp); |
| 485 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 485 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 486 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); | 486 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); |
| 487 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(temp->
asRenderTarget())); | 487 sk_sp<GrDrawContext> drawContext( |
| 488 this->drawContext(sk_ref_sp(temp->as
RenderTarget()))); |
| 488 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(),
rect, nullptr); | 489 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(),
rect, nullptr); |
| 489 surfaceToRead.reset(SkRef(temp.get())); | 490 surfaceToRead.reset(SkRef(temp.get())); |
| 490 left = 0; | 491 left = 0; |
| 491 top = 0; | 492 top = 0; |
| 492 didTempDraw = true; | 493 didTempDraw = true; |
| 493 } | 494 } |
| 494 } | 495 } |
| 495 } | 496 } |
| 496 | 497 |
| 497 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { | 498 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 return false; | 563 return false; |
| 563 } | 564 } |
| 564 // If we don't have an RT for the dst then we won't have a GrDrawContext
to insert the | 565 // If we don't have an RT for the dst then we won't have a GrDrawContext
to insert the |
| 565 // the copy surface into. In the future we plan to have a more limited C
ontext type | 566 // the copy surface into. In the future we plan to have a more limited C
ontext type |
| 566 // (GrCopyContext?) that has the subset of GrDrawContext operations that
should be | 567 // (GrCopyContext?) that has the subset of GrDrawContext operations that
should be |
| 567 // allowed on textures that aren't render targets. | 568 // allowed on textures that aren't render targets. |
| 568 // For now we just flush any writes to the src and issue an immediate co
py to the dst. | 569 // For now we just flush any writes to the src and issue an immediate co
py to the dst. |
| 569 src->flushWrites(); | 570 src->flushWrites(); |
| 570 return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint); | 571 return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint); |
| 571 } | 572 } |
| 572 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge
t())); | 573 sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst->asRenderTa
rget()))); |
| 573 if (!drawContext) { | 574 if (!drawContext) { |
| 574 return false; | 575 return false; |
| 575 } | 576 } |
| 576 | 577 |
| 577 if (!drawContext->copySurface(src, srcRect, dstPoint)) { | 578 if (!drawContext->copySurface(src, srcRect, dstPoint)) { |
| 578 return false; | 579 return false; |
| 579 } | 580 } |
| 580 return true; | 581 return true; |
| 581 } | 582 } |
| 582 | 583 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 601 if (dpi >= 250.0f) { | 602 if (dpi >= 250.0f) { |
| 602 chosenSampleCount = 4; | 603 chosenSampleCount = 4; |
| 603 } else { | 604 } else { |
| 604 chosenSampleCount = 16; | 605 chosenSampleCount = 16; |
| 605 } | 606 } |
| 606 } | 607 } |
| 607 return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? chosenSampleCou
nt : 0; | 608 return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? chosenSampleCou
nt : 0; |
| 608 } | 609 } |
| 609 | 610 |
| 610 | 611 |
| 611 GrDrawContext* GrContext::drawContext(GrRenderTarget* rt, const SkSurfaceProps*
surfaceProps) { | 612 sk_sp<GrDrawContext> GrContext::drawContext(sk_sp<GrRenderTarget> rt, |
| 613 const SkSurfaceProps* surfaceProps)
{ |
| 612 ASSERT_SINGLE_OWNER | 614 ASSERT_SINGLE_OWNER |
| 613 return fDrawingManager->drawContext(rt, surfaceProps); | 615 return fDrawingManager->drawContext(std::move(rt), surfaceProps); |
| 614 } | 616 } |
| 615 | 617 |
| 616 bool GrContext::abandoned() const { | 618 bool GrContext::abandoned() const { |
| 617 ASSERT_SINGLE_OWNER | 619 ASSERT_SINGLE_OWNER |
| 618 return fDrawingManager->abandoned(); | 620 return fDrawingManager->abandoned(); |
| 619 } | 621 } |
| 620 | 622 |
| 621 namespace { | 623 namespace { |
| 622 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { | 624 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { |
| 623 GrConfigConversionEffect::PMConversion pmToUPM; | 625 GrConfigConversionEffect::PMConversion pmToUPM; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 ASSERT_SINGLE_OWNER | 695 ASSERT_SINGLE_OWNER |
| 694 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 696 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 695 } | 697 } |
| 696 | 698 |
| 697 ////////////////////////////////////////////////////////////////////////////// | 699 ////////////////////////////////////////////////////////////////////////////// |
| 698 | 700 |
| 699 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 701 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 700 ASSERT_SINGLE_OWNER | 702 ASSERT_SINGLE_OWNER |
| 701 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 703 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 702 } | 704 } |
| OLD | NEW |