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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 if (!fTextContexts[props.pixelGeometry()][useDIF]) { | 121 if (!fTextContexts[props.pixelGeometry()][useDIF]) { |
122 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat
e(fContext, props); | 122 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat
e(fContext, props); |
123 } | 123 } |
124 | 124 |
125 return fTextContexts[props.pixelGeometry()][useDIF]; | 125 return fTextContexts[props.pixelGeometry()][useDIF]; |
126 } | 126 } |
127 | 127 |
128 GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceP
rops) { | 128 GrDrawContext* GrContext::DrawingMgr::drawContext(GrRenderTarget* rt, |
| 129 const SkSurfaceProps* surfaceP
rops) { |
129 if (this->abandoned()) { | 130 if (this->abandoned()) { |
130 return nullptr; | 131 return nullptr; |
131 } | 132 } |
132 | 133 |
133 return new GrDrawContext(fContext, fDrawTarget, surfaceProps); | 134 return new GrDrawContext(fContext, rt, fDrawTarget, surfaceProps); |
134 } | 135 } |
135 | 136 |
136 //////////////////////////////////////////////////////////////////////////////// | 137 //////////////////////////////////////////////////////////////////////////////// |
137 | 138 |
138 | 139 |
139 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext)
{ | 140 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext)
{ |
140 GrContextOptions defaultOptions; | 141 GrContextOptions defaultOptions; |
141 return Create(backend, backendContext, defaultOptions); | 142 return Create(backend, backendContext, defaultOptions); |
142 } | 143 } |
143 | 144 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 buffer = tmpPixels.get(); | 423 buffer = tmpPixels.get(); |
423 applyPremulToSrc = false; | 424 applyPremulToSrc = false; |
424 } | 425 } |
425 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, | 426 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, |
426 tempDrawInfo.fTempSurfaceDesc.fConfig, buffer
, | 427 tempDrawInfo.fTempSurfaceDesc.fConfig, buffer
, |
427 rowBytes)) { | 428 rowBytes)) { |
428 return false; | 429 return false; |
429 } | 430 } |
430 SkMatrix matrix; | 431 SkMatrix matrix; |
431 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); | 432 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
432 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); | 433 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarg
et)); |
433 if (!drawContext) { | 434 if (!drawContext) { |
434 return false; | 435 return false; |
435 } | 436 } |
436 paint.addColorFragmentProcessor(fp); | 437 paint.addColorFragmentProcessor(fp); |
437 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei
ght)); | 438 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei
ght)); |
438 drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matri
x, rect, nullptr); | 439 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp
tr); |
439 | 440 |
440 if (kFlushWrites_PixelOp & pixelOpsFlags) { | 441 if (kFlushWrites_PixelOp & pixelOpsFlags) { |
441 this->flushSurfaceWrites(surface); | 442 this->flushSurfaceWrites(surface); |
442 } | 443 } |
443 } | 444 } |
444 } | 445 } |
445 if (!tempTexture) { | 446 if (!tempTexture) { |
446 if (applyPremulToSrc) { | 447 if (applyPremulToSrc) { |
447 size_t tmpRowBytes = 4 * width; | 448 size_t tmpRowBytes = 4 * width; |
448 tmpPixels.reset(width * height); | 449 tmpPixels.reset(width * height); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 temp.reset(nullptr); | 535 temp.reset(nullptr); |
535 } | 536 } |
536 } | 537 } |
537 if (!fp && temp) { | 538 if (!fp && temp) { |
538 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp
DrawInfo.fSwapRAndB, | 539 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp
DrawInfo.fSwapRAndB, |
539 GrConfigConversionEffect::kNone_PMConversion, textureMatrix)
); | 540 GrConfigConversionEffect::kNone_PMConversion, textureMatrix)
); |
540 } | 541 } |
541 if (fp) { | 542 if (fp) { |
542 paint.addColorFragmentProcessor(fp); | 543 paint.addColorFragmentProcessor(fp); |
543 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); | 544 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); |
544 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); | 545 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(temp->
asRenderTarget())); |
545 drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen()
, paint, | 546 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(),
rect, nullptr); |
546 SkMatrix::I(), rect, nullptr); | |
547 surfaceToRead.reset(SkRef(temp.get())); | 547 surfaceToRead.reset(SkRef(temp.get())); |
548 left = 0; | 548 left = 0; |
549 top = 0; | 549 top = 0; |
550 didTempDraw = true; | 550 didTempDraw = true; |
551 } | 551 } |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { | 555 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { |
556 return false; | 556 return false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 610 } |
611 ASSERT_OWNED_RESOURCE(src); | 611 ASSERT_OWNED_RESOURCE(src); |
612 ASSERT_OWNED_RESOURCE(dst); | 612 ASSERT_OWNED_RESOURCE(dst); |
613 | 613 |
614 // Since we're going to the draw target and not GPU, no need to check kNoFlu
sh | 614 // Since we're going to the draw target and not GPU, no need to check kNoFlu
sh |
615 // here. | 615 // here. |
616 if (!dst->asRenderTarget()) { | 616 if (!dst->asRenderTarget()) { |
617 return; | 617 return; |
618 } | 618 } |
619 | 619 |
620 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); | 620 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge
t())); |
621 if (!drawContext) { | 621 if (!drawContext) { |
622 return; | 622 return; |
623 } | 623 } |
624 | 624 |
625 drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint); | 625 drawContext->copySurface(src, srcRect, dstPoint); |
626 | 626 |
627 if (kFlushWrites_PixelOp & pixelOpsFlags) { | 627 if (kFlushWrites_PixelOp & pixelOpsFlags) { |
628 this->flush(); | 628 this->flush(); |
629 } | 629 } |
630 } | 630 } |
631 | 631 |
632 void GrContext::flushSurfaceWrites(GrSurface* surface) { | 632 void GrContext::flushSurfaceWrites(GrSurface* surface) { |
633 RETURN_IF_ABANDONED | 633 RETURN_IF_ABANDONED |
634 if (surface->surfacePriv().hasPendingWrite()) { | 634 if (surface->surfacePriv().hasPendingWrite()) { |
635 this->flush(); | 635 this->flush(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 759 |
760 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ | 760 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ |
761 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 761 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
762 } | 762 } |
763 | 763 |
764 ////////////////////////////////////////////////////////////////////////////// | 764 ////////////////////////////////////////////////////////////////////////////// |
765 | 765 |
766 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 766 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
767 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 767 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
768 } | 768 } |
OLD | NEW |