OLD | NEW |
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 "GrBatch.h" | 9 #include "GrBatch.h" |
10 #include "GrBatchFontCache.h" | 10 #include "GrBatchFontCache.h" |
(...skipping 1703 matching lines...) Loading... |
1714 int instanceCount() const { return fInstanceCount; } | 1714 int instanceCount() const { return fInstanceCount; } |
1715 SkAutoSTMalloc<kMinAllocated, Geometry>* geoData() { return &fGeoData; } | 1715 SkAutoSTMalloc<kMinAllocated, Geometry>* geoData() { return &fGeoData; } |
1716 | 1716 |
1717 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which | 1717 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which |
1718 // is used to seed the batch with its initial geometry. After seeding, the
client should call | 1718 // is used to seed the batch with its initial geometry. After seeding, the
client should call |
1719 // init() so the Batch can initialize itself | 1719 // init() so the Batch can initialize itself |
1720 Geometry& geometry() { return fGeoData[0]; } | 1720 Geometry& geometry() { return fGeoData[0]; } |
1721 void init() { | 1721 void init() { |
1722 fBatch.fColor = fGeoData[0].fColor; | 1722 fBatch.fColor = fGeoData[0].fColor; |
1723 fBatch.fViewMatrix = fGeoData[0].fBlob->fViewMatrix; | 1723 fBatch.fViewMatrix = fGeoData[0].fBlob->fViewMatrix; |
| 1724 this->setBounds(fGeoData[0].fBlob->fRuns[fGeoData[0].fRun].fVertexBounds
); |
1724 } | 1725 } |
1725 | 1726 |
1726 private: | 1727 private: |
1727 BitmapTextBatch(GrMaskFormat maskFormat, int glyphCount, GrBatchFontCache* f
ontCache) | 1728 BitmapTextBatch(GrMaskFormat maskFormat, int glyphCount, GrBatchFontCache* f
ontCache) |
1728 : fMaskFormat(maskFormat) | 1729 : fMaskFormat(maskFormat) |
1729 , fPixelConfig(fontCache->getPixelConfig(maskFormat)) | 1730 , fPixelConfig(fontCache->getPixelConfig(maskFormat)) |
1730 , fFontCache(fontCache) | 1731 , fFontCache(fontCache) |
1731 , fUseDistanceFields(false) { | 1732 , fUseDistanceFields(false) { |
1732 this->initClassID<BitmapTextBatch>(); | 1733 this->initClassID<BitmapTextBatch>(); |
1733 fBatch.fNumGlyphs = glyphCount; | 1734 fBatch.fNumGlyphs = glyphCount; |
(...skipping 183 matching lines...) Loading... |
1917 fGeoData.realloc(fAllocatedCount); | 1918 fGeoData.realloc(fAllocatedCount); |
1918 } | 1919 } |
1919 | 1920 |
1920 memcpy(&fGeoData[fInstanceCount], otherGeoData->get(), | 1921 memcpy(&fGeoData[fInstanceCount], otherGeoData->get(), |
1921 otherInstanceCount * sizeof(Geometry)); | 1922 otherInstanceCount * sizeof(Geometry)); |
1922 int total = fInstanceCount + otherInstanceCount; | 1923 int total = fInstanceCount + otherInstanceCount; |
1923 for (int i = fInstanceCount; i < total; i++) { | 1924 for (int i = fInstanceCount; i < total; i++) { |
1924 fGeoData[i].fBlob->ref(); | 1925 fGeoData[i].fBlob->ref(); |
1925 } | 1926 } |
1926 fInstanceCount = total; | 1927 fInstanceCount = total; |
| 1928 |
| 1929 this->joinBounds(that->bounds()); |
1927 return true; | 1930 return true; |
1928 } | 1931 } |
1929 | 1932 |
1930 // TODO just use class params | 1933 // TODO just use class params |
1931 // TODO trying to figure out why lcd is so whack | 1934 // TODO trying to figure out why lcd is so whack |
1932 GrGeometryProcessor* setupDfProcessor(const SkMatrix& viewMatrix, SkColor fi
lteredColor, | 1935 GrGeometryProcessor* setupDfProcessor(const SkMatrix& viewMatrix, SkColor fi
lteredColor, |
1933 GrColor color, GrTexture* texture) { | 1936 GrColor color, GrTexture* texture) { |
1934 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile
rp_FilterMode); | 1937 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile
rp_FilterMode); |
1935 | 1938 |
1936 // set up any flags | 1939 // set up any flags |
(...skipping 148 matching lines...) Loading... |
2085 } | 2088 } |
2086 BitmapTextBatch::Geometry& geometry = batch->geometry(); | 2089 BitmapTextBatch::Geometry& geometry = batch->geometry(); |
2087 geometry.fBlob = SkRef(cacheBlob); | 2090 geometry.fBlob = SkRef(cacheBlob); |
2088 geometry.fRun = run; | 2091 geometry.fRun = run; |
2089 geometry.fSubRun = subRun; | 2092 geometry.fSubRun = subRun; |
2090 geometry.fColor = subRunColor; | 2093 geometry.fColor = subRunColor; |
2091 geometry.fTransX = transX; | 2094 geometry.fTransX = transX; |
2092 geometry.fTransY = transY; | 2095 geometry.fTransY = transY; |
2093 batch->init(); | 2096 batch->init(); |
2094 | 2097 |
2095 target->drawBatch(pipelineBuilder, batch, &cacheBlob->fRuns[run].fVertex
Bounds); | 2098 target->drawBatch(pipelineBuilder, batch); |
2096 } | 2099 } |
2097 } | 2100 } |
2098 | 2101 |
2099 inline void GrAtlasTextContext::flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRend
erTarget* rt, | 2102 inline void GrAtlasTextContext::flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRend
erTarget* rt, |
2100 const GrPaint& grPaint, const GrC
lip& clip, | 2103 const GrPaint& grPaint, const GrC
lip& clip, |
2101 SkScalar transX, SkScalar transY)
{ | 2104 SkScalar transX, SkScalar transY)
{ |
2102 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { | 2105 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { |
2103 BitmapTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; | 2106 BitmapTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; |
2104 bigGlyph.fVx += SkScalarTruncToInt(transX); | 2107 bigGlyph.fVx += SkScalarTruncToInt(transX); |
2105 bigGlyph.fVy += SkScalarTruncToInt(transY); | 2108 bigGlyph.fVy += SkScalarTruncToInt(transY); |
(...skipping 50 matching lines...) Loading... |
2156 pipelineBuilder.setFromPaint(grPaint, rt, clip); | 2159 pipelineBuilder.setFromPaint(grPaint, rt, clip); |
2157 | 2160 |
2158 GrColor color = grPaint.getColor(); | 2161 GrColor color = grPaint.getColor(); |
2159 for (int run = 0; run < cacheBlob->fRunCount; run++) { | 2162 for (int run = 0; run < cacheBlob->fRunCount; run++) { |
2160 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk
Paint); | 2163 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk
Paint); |
2161 } | 2164 } |
2162 | 2165 |
2163 // Now flush big glyphs | 2166 // Now flush big glyphs |
2164 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); | 2167 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); |
2165 } | 2168 } |
OLD | NEW |