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 const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps)); | 120 const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps)); |
121 | 121 |
122 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); | 122 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); |
123 if (!fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()
]) { | 123 if (!fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()
]) { |
124 fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]
= | 124 fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]
= |
125 new GrDrawContext(fContext, fDrawTarget, props); | 125 new GrDrawContext(fContext, fDrawTarget, props); |
126 } | 126 } |
127 | 127 |
128 return fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts
()]; | 128 // For now, everyone gets a faux creation ref |
| 129 return SkRef(fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependen
tFonts()]); |
129 } | 130 } |
130 | 131 |
131 //////////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////////// |
132 | 133 |
133 | 134 |
134 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext)
{ | 135 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext)
{ |
135 GrContextOptions defaultOptions; | 136 GrContextOptions defaultOptions; |
136 return Create(backend, backendContext, defaultOptions); | 137 return Create(backend, backendContext, defaultOptions); |
137 } | 138 } |
138 | 139 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 buffer = tmpPixels.get(); | 417 buffer = tmpPixels.get(); |
417 applyPremulToSrc = false; | 418 applyPremulToSrc = false; |
418 } | 419 } |
419 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, | 420 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, |
420 tempDrawInfo.fTempSurfaceDesc.fConfig, buffer
, | 421 tempDrawInfo.fTempSurfaceDesc.fConfig, buffer
, |
421 rowBytes)) { | 422 rowBytes)) { |
422 return false; | 423 return false; |
423 } | 424 } |
424 SkMatrix matrix; | 425 SkMatrix matrix; |
425 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); | 426 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
426 GrDrawContext* drawContext = this->drawContext(); | 427 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); |
427 if (!drawContext) { | 428 if (!drawContext) { |
428 return false; | 429 return false; |
429 } | 430 } |
430 paint.addColorFragmentProcessor(fp); | 431 paint.addColorFragmentProcessor(fp); |
431 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei
ght)); | 432 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei
ght)); |
432 drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matri
x, rect, nullptr); | 433 drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matri
x, rect, nullptr); |
433 | 434 |
434 if (kFlushWrites_PixelOp & pixelOpsFlags) { | 435 if (kFlushWrites_PixelOp & pixelOpsFlags) { |
435 this->flushSurfaceWrites(surface); | 436 this->flushSurfaceWrites(surface); |
436 } | 437 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 } | 528 } |
528 } | 529 } |
529 if (!fp && temp) { | 530 if (!fp && temp) { |
530 fp.reset(GrConfigConversionEffect::Create( | 531 fp.reset(GrConfigConversionEffect::Create( |
531 paint.getProcessorDataManager(), src->asTexture(), tempDrawI
nfo.fSwapRAndB, | 532 paint.getProcessorDataManager(), src->asTexture(), tempDrawI
nfo.fSwapRAndB, |
532 GrConfigConversionEffect::kNone_PMConversion, textureMatrix)
); | 533 GrConfigConversionEffect::kNone_PMConversion, textureMatrix)
); |
533 } | 534 } |
534 if (fp) { | 535 if (fp) { |
535 paint.addColorFragmentProcessor(fp); | 536 paint.addColorFragmentProcessor(fp); |
536 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); | 537 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar
(height)); |
537 GrDrawContext* drawContext = this->drawContext(); | 538 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); |
538 drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen()
, paint, | 539 drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen()
, paint, |
539 SkMatrix::I(), rect, nullptr); | 540 SkMatrix::I(), rect, nullptr); |
540 surfaceToRead.reset(SkRef(temp.get())); | 541 surfaceToRead.reset(SkRef(temp.get())); |
541 left = 0; | 542 left = 0; |
542 top = 0; | 543 top = 0; |
543 didTempDraw = true; | 544 didTempDraw = true; |
544 } | 545 } |
545 } | 546 } |
546 } | 547 } |
547 | 548 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 } | 604 } |
604 ASSERT_OWNED_RESOURCE(src); | 605 ASSERT_OWNED_RESOURCE(src); |
605 ASSERT_OWNED_RESOURCE(dst); | 606 ASSERT_OWNED_RESOURCE(dst); |
606 | 607 |
607 // Since we're going to the draw target and not GPU, no need to check kNoFlu
sh | 608 // Since we're going to the draw target and not GPU, no need to check kNoFlu
sh |
608 // here. | 609 // here. |
609 if (!dst->asRenderTarget()) { | 610 if (!dst->asRenderTarget()) { |
610 return; | 611 return; |
611 } | 612 } |
612 | 613 |
613 GrDrawContext* drawContext = this->drawContext(); | 614 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); |
614 if (!drawContext) { | 615 if (!drawContext) { |
615 return; | 616 return; |
616 } | 617 } |
617 | 618 |
618 drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint); | 619 drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint); |
619 | 620 |
620 if (kFlushWrites_PixelOp & pixelOpsFlags) { | 621 if (kFlushWrites_PixelOp & pixelOpsFlags) { |
621 this->flush(); | 622 this->flush(); |
622 } | 623 } |
623 } | 624 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 ////////////////////////////////////////////////////////////////////////////// | 755 ////////////////////////////////////////////////////////////////////////////// |
755 | 756 |
756 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { | 757 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { |
757 fGpu->addGpuTraceMarker(marker); | 758 fGpu->addGpuTraceMarker(marker); |
758 } | 759 } |
759 | 760 |
760 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 761 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
761 fGpu->removeGpuTraceMarker(marker); | 762 fGpu->removeGpuTraceMarker(marker); |
762 } | 763 } |
763 | 764 |
OLD | NEW |