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

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

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Removing the concept of a dirty mipmap. It is expected that the texture upload provides the mipmaps. Created 5 years, 3 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #include "GrAtlasTextContext.h" 7 #include "GrAtlasTextContext.h"
8 8
9 #include "GrBatchFontCache.h" 9 #include "GrBatchFontCache.h"
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 return true; 480 return true;
481 } 481 }
482 482
483 void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, 483 void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
484 const SkPaint& skPaint, GrColor colo r, 484 const SkPaint& skPaint, GrColor colo r,
485 const SkMatrix& viewMatrix, 485 const SkMatrix& viewMatrix,
486 const SkTextBlob* blob, SkScalar x, SkScalar y, 486 const SkTextBlob* blob, SkScalar x, SkScalar y,
487 SkDrawFilter* drawFilter, const SkIR ect& clipRect, 487 SkDrawFilter* drawFilter, const SkIR ect& clipRect,
488 GrRenderTarget* rt, const GrClip& cl ip) { 488 GrRenderTarget* rt, const GrClip& cl ip) {
489 // The color here is the GrPaint color, and it is used to determine whether we 489 // The color here is the GrPaint color, and it is used to determine whether we
490 // have to regenerate LCD text blobs. 490 // have to regenerate LCD text blobs.
491 // We use this color vs the SkPaint color because it has the colorfilter app lied. 491 // We use this color vs the SkPaint color because it has the colorfilter app lied.
492 cacheBlob->fPaintColor = color; 492 cacheBlob->fPaintColor = color;
493 cacheBlob->fViewMatrix = viewMatrix; 493 cacheBlob->fViewMatrix = viewMatrix;
494 cacheBlob->fX = x; 494 cacheBlob->fX = x;
495 cacheBlob->fY = y; 495 cacheBlob->fY = y;
496 496
497 // Regenerate textblob 497 // Regenerate textblob
498 SkPaint runPaint = skPaint; 498 SkPaint runPaint = skPaint;
499 SkTextBlob::RunIterator it(blob); 499 SkTextBlob::RunIterator it(blob);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 SkScalar textRatio; 717 SkScalar textRatio;
718 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); 718 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio);
719 719
720 SkTDArray<char> fallbackTxt; 720 SkTDArray<char> fallbackTxt;
721 SkTDArray<SkScalar> fallbackPos; 721 SkTDArray<SkScalar> fallbackPos;
722 SkPoint offset; 722 SkPoint offset;
723 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text, 723 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text,
724 byteLength, x, y, clipRect, textRatio, &fallbac kTxt, &fallbackPos, 724 byteLength, x, y, clipRect, textRatio, &fallbac kTxt, &fallbackPos,
725 &offset, skPaint); 725 &offset, skPaint);
726 if (fallbackTxt.count()) { 726 if (fallbackTxt.count()) {
727 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai nt, viewMatrix, 727 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai nt, viewMatrix,
728 fallbackTxt, fallbackPos, 2, offset, clipR ect); 728 fallbackTxt, fallbackPos, 2, offset, clipR ect);
729 } 729 }
730 } else { 730 } else {
731 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); 731 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
732 blob->fViewMatrix = viewMatrix; 732 blob->fViewMatrix = viewMatrix;
733 733
734 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); 734 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false);
735 this->internalDrawBMPText(blob, 0, cache, skPaint, paint.getColor(), vie wMatrix, text, 735 this->internalDrawBMPText(blob, 0, cache, skPaint, paint.getColor(), vie wMatrix, text,
736 byteLength, x, y, clipRect); 736 byteLength, x, y, clipRect);
737 SkGlyphCache::AttachCache(cache); 737 SkGlyphCache::AttachCache(cache);
(...skipping 18 matching lines...) Expand all
756 SkPaint dfPaint; 756 SkPaint dfPaint;
757 SkScalar textRatio; 757 SkScalar textRatio;
758 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); 758 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio);
759 759
760 SkTDArray<char> fallbackTxt; 760 SkTDArray<char> fallbackTxt;
761 SkTDArray<SkScalar> fallbackPos; 761 SkTDArray<SkScalar> fallbackPos;
762 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr ix, text, 762 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr ix, text,
763 byteLength, pos, scalarsPerPosition, offset, clipRect, 763 byteLength, pos, scalarsPerPosition, offset, clipRect,
764 textRatio, &fallbackTxt, &fallbackPos); 764 textRatio, &fallbackTxt, &fallbackPos);
765 if (fallbackTxt.count()) { 765 if (fallbackTxt.count()) {
766 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai nt, viewMatrix, 766 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai nt, viewMatrix,
767 fallbackTxt, fallbackPos, scalarsPerPositi on, offset, 767 fallbackTxt, fallbackPos, scalarsPerPositi on, offset,
768 clipRect); 768 clipRect);
769 } 769 }
770 } else { 770 } else {
771 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); 771 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
772 blob->fViewMatrix = viewMatrix; 772 blob->fViewMatrix = viewMatrix;
773 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); 773 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false);
774 this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(), viewMatrix, text, 774 this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(), viewMatrix, text,
775 byteLength, pos, scalarsPerPosition, offset , clipRect); 775 byteLength, pos, scalarsPerPosition, offset , clipRect);
776 SkGlyphCache::AttachCache(cache); 776 SkGlyphCache::AttachCache(cache);
777 } 777 }
778 return blob; 778 return blob;
779 } 779 }
780 780
781 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt, 781 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt,
782 const GrClip& clip, 782 const GrClip& clip,
783 const GrPaint& paint, const SkPaint& skPaint , 783 const GrPaint& paint, const SkPaint& skPaint ,
784 const SkMatrix& viewMatrix, 784 const SkMatrix& viewMatrix,
785 const char text[], size_t byteLength, 785 const char text[], size_t byteLength,
786 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) { 786 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) {
787 SkAutoTUnref<GrAtlasTextBlob> blob( 787 SkAutoTUnref<GrAtlasTextBlob> blob(
788 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix, 788 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix,
789 text, byteLength, x, y, regionClipBounds)); 789 text, byteLength, x, y, regionClipBounds));
790 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); 790 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds);
791 } 791 }
792 792
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 bool fUseBGR; // fold this into the enum? 2040 bool fUseBGR; // fold this into the enum?
2041 2041
2042 GrBatchFontCache* fFontCache; 2042 GrBatchFontCache* fFontCache;
2043 2043
2044 // Distance field properties 2044 // Distance field properties
2045 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; 2045 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable;
2046 SkColor fFilteredColor; 2046 SkColor fFilteredColor;
2047 }; 2047 };
2048 2048
2049 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt, 2049 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
2050 const SkTextBlob::RunIterator& it, 2050 const SkTextBlob::RunIterator& it,
2051 const GrClip& clip, const SkPaint& skPa int, 2051 const GrClip& clip, const SkPaint& skPa int,
2052 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix, 2052 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix,
2053 const SkIRect& clipBounds, SkScalar x, SkScalar y) { 2053 const SkIRect& clipBounds, SkScalar x, SkScalar y) {
2054 SkPaint runPaint = skPaint; 2054 SkPaint runPaint = skPaint;
2055 2055
2056 size_t textLen = it.glyphCount() * sizeof(uint16_t); 2056 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2057 const SkPoint& offset = it.offset(); 2057 const SkPoint& offset = it.offset();
2058 2058
2059 it.applyFontToPaint(&runPaint); 2059 it.applyFontToPaint(&runPaint);
2060 2060
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps); 2240 gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps);
2241 } 2241 }
2242 2242
2243 // create dummy render target 2243 // create dummy render target
2244 GrSurfaceDesc desc; 2244 GrSurfaceDesc desc;
2245 desc.fFlags = kRenderTarget_GrSurfaceFlag; 2245 desc.fFlags = kRenderTarget_GrSurfaceFlag;
2246 desc.fWidth = 1024; 2246 desc.fWidth = 1024;
2247 desc.fHeight = 1024; 2247 desc.fHeight = 1024;
2248 desc.fConfig = kRGBA_8888_GrPixelConfig; 2248 desc.fConfig = kRGBA_8888_GrPixelConfig;
2249 desc.fSampleCnt = 0; 2249 desc.fSampleCnt = 0;
2250 desc.fIsMipMapped = false;
2250 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0)); 2251 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0));
2251 SkASSERT(texture); 2252 SkASSERT(texture);
2252 SkASSERT(nullptr != texture->asRenderTarget()); 2253 SkASSERT(nullptr != texture->asRenderTarget());
2253 GrRenderTarget* rt = texture->asRenderTarget(); 2254 GrRenderTarget* rt = texture->asRenderTarget();
2254 2255
2255 // Setup dummy SkPaint / GrPaint 2256 // Setup dummy SkPaint / GrPaint
2256 GrColor color = GrRandomColor(random); 2257 GrColor color = GrRandomColor(random);
2257 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 2258 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
2258 SkPaint skPaint; 2259 SkPaint skPaint;
2259 skPaint.setColor(color); 2260 skPaint.setColor(color);
(...skipping 19 matching lines...) Expand all
2279 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2280 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2280 static_cast<size_t>(textLen), 0, 0, noClip)); 2281 static_cast<size_t>(textLen), 0, 0, noClip));
2281 2282
2282 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2283 SkScalar transX = static_cast<SkScalar>(random->nextU());
2283 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2284 SkScalar transY = static_cast<SkScalar>(random->nextU());
2284 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2285 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2285 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2286 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2286 } 2287 }
2287 2288
2288 #endif 2289 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698