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

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

Issue 1413673002: Remove DrawingMgr shims from GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove abandon, reset & flush from public DrawingMgr API 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
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr ovider()); 146 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr ovider());
147 147
148 *fDrawTargets.append() = dt; 148 *fDrawTargets.append() = dt;
149 149
150 // DrawingMgr gets the creation ref - this ref is for the caller 150 // DrawingMgr gets the creation ref - this ref is for the caller
151 return SkRef(dt); 151 return SkRef(dt);
152 } 152 }
153 153
154 GrDrawContext* GrContext::DrawingMgr::drawContext(GrRenderTarget* rt, 154 GrDrawContext* GrContext::DrawingMgr::drawContext(GrRenderTarget* rt,
155 const SkSurfaceProps* surfaceP rops) { 155 const SkSurfaceProps* surfaceP rops) const {
156 if (this->abandoned()) { 156 if (this->abandoned()) {
157 return nullptr; 157 return nullptr;
158 } 158 }
159 159
160 return new GrDrawContext(fContext, rt, surfaceProps); 160 return new GrDrawContext(const_cast<DrawingMgr*>(this), rt, surfaceProps);
161 } 161 }
162 162
163 //////////////////////////////////////////////////////////////////////////////// 163 ////////////////////////////////////////////////////////////////////////////////
164 164
165 165
166 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { 166 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
167 GrContextOptions defaultOptions; 167 GrContextOptions defaultOptions;
168 return Create(backend, backendContext, defaultOptions); 168 return Create(backend, backendContext, defaultOptions);
169 } 169 }
170 170
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 buffer = tmpPixels.get(); 449 buffer = tmpPixels.get();
450 applyPremulToSrc = false; 450 applyPremulToSrc = false;
451 } 451 }
452 if (!fGpu->writePixels(tempTexture, 0, 0, width, height, 452 if (!fGpu->writePixels(tempTexture, 0, 0, width, height,
453 tempDrawInfo.fTempSurfaceDesc.fConfig, buffer , 453 tempDrawInfo.fTempSurfaceDesc.fConfig, buffer ,
454 rowBytes)) { 454 rowBytes)) {
455 return false; 455 return false;
456 } 456 }
457 SkMatrix matrix; 457 SkMatrix matrix;
458 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); 458 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
459 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarg et)); 459 SkAutoTUnref<GrDrawContext> drawContext(fDrawingMgr.drawContext(rend erTarget));
460 if (!drawContext) { 460 if (!drawContext) {
461 return false; 461 return false;
462 } 462 }
463 paint.addColorFragmentProcessor(fp); 463 paint.addColorFragmentProcessor(fp);
464 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei ght)); 464 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(hei ght));
465 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp tr); 465 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp tr);
466 466
467 if (kFlushWrites_PixelOp & pixelOpsFlags) { 467 if (kFlushWrites_PixelOp & pixelOpsFlags) {
468 this->flushSurfaceWrites(surface); 468 this->flushSurfaceWrites(surface);
469 } 469 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 temp.reset(nullptr); 561 temp.reset(nullptr);
562 } 562 }
563 } 563 }
564 if (!fp && temp) { 564 if (!fp && temp) {
565 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp DrawInfo.fSwapRAndB, 565 fp.reset(GrConfigConversionEffect::Create(src->asTexture(), temp DrawInfo.fSwapRAndB,
566 GrConfigConversionEffect::kNone_PMConversion, textureMatrix) ); 566 GrConfigConversionEffect::kNone_PMConversion, textureMatrix) );
567 } 567 }
568 if (fp) { 568 if (fp) {
569 paint.addColorFragmentProcessor(fp); 569 paint.addColorFragmentProcessor(fp);
570 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar (height)); 570 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar (height));
571 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(temp-> asRenderTarget())); 571 SkAutoTUnref<GrDrawContext> drawContext(
572 fDrawingMgr.drawContext(temp->as RenderTarget()));
572 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, nullptr); 573 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, nullptr);
573 surfaceToRead.reset(SkRef(temp.get())); 574 surfaceToRead.reset(SkRef(temp.get()));
574 left = 0; 575 left = 0;
575 top = 0; 576 top = 0;
576 didTempDraw = true; 577 didTempDraw = true;
577 } 578 }
578 } 579 }
579 } 580 }
580 581
581 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { 582 if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 637 }
637 ASSERT_OWNED_RESOURCE(src); 638 ASSERT_OWNED_RESOURCE(src);
638 ASSERT_OWNED_RESOURCE(dst); 639 ASSERT_OWNED_RESOURCE(dst);
639 640
640 // Since we're going to the draw target and not GPU, no need to check kNoFlu sh 641 // Since we're going to the draw target and not GPU, no need to check kNoFlu sh
641 // here. 642 // here.
642 if (!dst->asRenderTarget()) { 643 if (!dst->asRenderTarget()) {
643 return; 644 return;
644 } 645 }
645 646
646 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge t())); 647 SkAutoTUnref<GrDrawContext> drawContext(fDrawingMgr.drawContext(dst->asRende rTarget()));
647 if (!drawContext) { 648 if (!drawContext) {
648 return; 649 return;
649 } 650 }
650 651
651 drawContext->copySurface(src, srcRect, dstPoint); 652 drawContext->copySurface(src, srcRect, dstPoint);
652 653
653 if (kFlushWrites_PixelOp & pixelOpsFlags) { 654 if (kFlushWrites_PixelOp & pixelOpsFlags) {
654 this->flush(); 655 this->flush();
655 } 656 }
656 } 657 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 786
786 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { 787 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) {
787 fResourceCache->setLimits(maxTextures, maxTextureBytes); 788 fResourceCache->setLimits(maxTextures, maxTextureBytes);
788 } 789 }
789 790
790 ////////////////////////////////////////////////////////////////////////////// 791 //////////////////////////////////////////////////////////////////////////////
791 792
792 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 793 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
793 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 794 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
794 } 795 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698