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

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: Fixing incorrect rebase. 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 * 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 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 GrBatchFontCache* fFontCache; 2043 GrBatchFontCache* fFontCache;
2044 2044
2045 // Distance field properties 2045 // Distance field properties
2046 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; 2046 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable;
2047 SkColor fFilteredColor; 2047 SkColor fFilteredColor;
2048 2048
2049 typedef GrVertexBatch INHERITED; 2049 typedef GrVertexBatch INHERITED;
2050 }; 2050 };
2051 2051
2052 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt, 2052 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
2053 const SkTextBlob::RunIterator& it, 2053 const SkTextBlob::RunIterator& it,
2054 const GrClip& clip, const SkPaint& skPa int, 2054 const GrClip& clip, const SkPaint& skPa int,
2055 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix, 2055 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix,
2056 const SkIRect& clipBounds, SkScalar x, SkScalar y) { 2056 const SkIRect& clipBounds, SkScalar x, SkScalar y) {
2057 SkPaint runPaint = skPaint; 2057 SkPaint runPaint = skPaint;
2058 2058
2059 size_t textLen = it.glyphCount() * sizeof(uint16_t); 2059 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2060 const SkPoint& offset = it.offset(); 2060 const SkPoint& offset = it.offset();
2061 2061
2062 it.applyFontToPaint(&runPaint); 2062 it.applyFontToPaint(&runPaint);
2063 2063
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps); 2243 gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps);
2244 } 2244 }
2245 2245
2246 // create dummy render target 2246 // create dummy render target
2247 GrSurfaceDesc desc; 2247 GrSurfaceDesc desc;
2248 desc.fFlags = kRenderTarget_GrSurfaceFlag; 2248 desc.fFlags = kRenderTarget_GrSurfaceFlag;
2249 desc.fWidth = 1024; 2249 desc.fWidth = 1024;
2250 desc.fHeight = 1024; 2250 desc.fHeight = 1024;
2251 desc.fConfig = kRGBA_8888_GrPixelConfig; 2251 desc.fConfig = kRGBA_8888_GrPixelConfig;
2252 desc.fSampleCnt = 0; 2252 desc.fSampleCnt = 0;
2253 desc.fIsMipMapped = false;
2253 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0)); 2254 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0));
2254 SkASSERT(texture); 2255 SkASSERT(texture);
2255 SkASSERT(nullptr != texture->asRenderTarget()); 2256 SkASSERT(nullptr != texture->asRenderTarget());
2256 GrRenderTarget* rt = texture->asRenderTarget(); 2257 GrRenderTarget* rt = texture->asRenderTarget();
2257 2258
2258 // Setup dummy SkPaint / GrPaint 2259 // Setup dummy SkPaint / GrPaint
2259 GrColor color = GrRandomColor(random); 2260 GrColor color = GrRandomColor(random);
2260 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 2261 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
2261 SkPaint skPaint; 2262 SkPaint skPaint;
2262 skPaint.setColor(color); 2263 skPaint.setColor(color);
(...skipping 19 matching lines...) Expand all
2282 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2283 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2283 static_cast<size_t>(textLen), 0, 0, noClip)); 2284 static_cast<size_t>(textLen), 0, 0, noClip));
2284 2285
2285 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2286 SkScalar transX = static_cast<SkScalar>(random->nextU());
2286 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2287 SkScalar transY = static_cast<SkScalar>(random->nextU());
2287 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2288 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2288 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2289 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2289 } 2290 }
2290 2291
2291 #endif 2292 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698