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

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

Issue 1260183006: Move atlas creation to internal to GrResourceProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@debugatlas
Patch Set: tweak Created 5 years, 4 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
« no previous file with comments | « no previous file | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 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 "GrAADistanceFieldPathRenderer.h" 9 #include "GrAADistanceFieldPathRenderer.h"
10 10
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 bool fCoverageIgnored; 522 bool fCoverageIgnored;
523 }; 523 };
524 524
525 BatchTracker fBatch; 525 BatchTracker fBatch;
526 SkSTArray<1, Geometry, true> fGeoData; 526 SkSTArray<1, Geometry, true> fGeoData;
527 GrBatchAtlas* fAtlas; 527 GrBatchAtlas* fAtlas;
528 PathCache* fPathCache; 528 PathCache* fPathCache;
529 PathDataList* fPathList; 529 PathDataList* fPathList;
530 }; 530 };
531 531
532 static GrBatchAtlas* create_atlas(GrResourceProvider* provider, GrBatchAtlas::Ev ictionFunc func,
533 void* data) {
534 GrBatchAtlas* atlas;
535 // Create a new atlas
536 GrSurfaceDesc desc;
537 desc.fFlags = kNone_GrSurfaceFlags;
538 desc.fWidth = ATLAS_TEXTURE_WIDTH;
539 desc.fHeight = ATLAS_TEXTURE_HEIGHT;
540 desc.fConfig = kAlpha_8_GrPixelConfig;
541
542 // We don't want to flush the context so we claim we're in the middle of flu shing so as to
543 // guarantee we do not recieve a texture with pending IO
544 // TODO: Determine how to avoid having to do this. (http://skbug.com/4156)
545 static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag;
546 GrTexture* texture = provider->createApproxTexture(desc, kFlags);
547 if (texture) {
548 atlas = SkNEW_ARGS(GrBatchAtlas, (texture, NUM_PLOTS_X, NUM_PLOTS_Y));
549 } else {
550 return NULL;
551 }
552 atlas->registerEvictionCallback(func, data);
553 return atlas;
554 }
555
556 bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { 532 bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
557 // we've already bailed on inverse filled paths, so this is safe 533 // we've already bailed on inverse filled paths, so this is safe
558 if (args.fPath->isEmpty()) { 534 if (args.fPath->isEmpty()) {
559 return true; 535 return true;
560 } 536 }
561 537
562 if (!fAtlas) { 538 if (!fAtlas) {
563 fAtlas = create_atlas(args.fResourceProvider, 539 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig,
564 &GrAADistanceFieldPathRenderer::HandleEviction, (v oid*)this); 540 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT,
541 NUM_PLOTS_X, NUM_PLOTS_Y,
542 &GrAADistanceFieldPathRende rer::HandleEviction,
543 (void*)this);
565 if (!fAtlas) { 544 if (!fAtlas) {
566 return false; 545 return false;
567 } 546 }
568 } 547 }
569 548
570 AADistanceFieldPathBatch::Geometry geometry(*args.fStroke); 549 AADistanceFieldPathBatch::Geometry geometry(*args.fStroke);
571 geometry.fPath = *args.fPath; 550 geometry.fPath = *args.fPath;
572 geometry.fAntiAlias = args.fAntiAlias; 551 geometry.fAntiAlias = args.fAntiAlias;
573 552
574 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, args. fColor, 553 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, args. fColor,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 PathCache fPathCache; 603 PathCache fPathCache;
625 PathDataList fPathList; 604 PathDataList fPathList;
626 }; 605 };
627 606
628 BATCH_TEST_DEFINE(AADistanceFieldPathBatch) { 607 BATCH_TEST_DEFINE(AADistanceFieldPathBatch) {
629 static PathTestStruct gTestStruct; 608 static PathTestStruct gTestStruct;
630 609
631 if (context->uniqueID() != gTestStruct.fContextID) { 610 if (context->uniqueID() != gTestStruct.fContextID) {
632 gTestStruct.fContextID = context->uniqueID(); 611 gTestStruct.fContextID = context->uniqueID();
633 gTestStruct.reset(); 612 gTestStruct.reset();
634 gTestStruct.fAtlas = create_atlas(context->resourceProvider(), 613 gTestStruct.fAtlas =
635 &PathTestStruct::HandleEviction, (void *)&gTestStruct); 614 context->resourceProvider()->createAtlas(kAlpha_8_GrPixelConfig,
615 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT,
616 NUM_PLOTS_X, NUM_PLOTS_Y,
617 &PathTestStruct::HandleEvic tion,
618 (void*)&gTestStruct);
636 } 619 }
637 620
638 SkMatrix viewMatrix = GrTest::TestMatrix(random); 621 SkMatrix viewMatrix = GrTest::TestMatrix(random);
639 GrColor color = GrRandomColor(random); 622 GrColor color = GrRandomColor(random);
640 623
641 AADistanceFieldPathBatch::Geometry geometry(GrTest::TestStrokeRec(random)); 624 AADistanceFieldPathBatch::Geometry geometry(GrTest::TestStrokeRec(random));
642 geometry.fPath = GrTest::TestPath(random); 625 geometry.fPath = GrTest::TestPath(random);
643 geometry.fAntiAlias = random->nextBool(); 626 geometry.fAntiAlias = random->nextBool();
644 627
645 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, 628 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix,
646 gTestStruct.fAtlas, 629 gTestStruct.fAtlas,
647 &gTestStruct.fPathCache, 630 &gTestStruct.fPathCache,
648 &gTestStruct.fPathList); 631 &gTestStruct.fPathList);
649 } 632 }
650 633
651 #endif 634 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698