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

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

Issue 1353043002: Revert of add a ClassID function to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrDrawTarget.h » ('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 * 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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 position = reinterpret_cast<SkPoint*>(vertex); 1424 position = reinterpret_cast<SkPoint*>(vertex);
1425 position->set(positions.fRight, positions.fTop); 1425 position->set(positions.fRight, positions.fTop);
1426 } 1426 }
1427 1427
1428 subRun->fGlyphEndIndex++; 1428 subRun->fGlyphEndIndex++;
1429 subRun->fVertexEndIndex += vertexStride * kVerticesPerGlyph; 1429 subRun->fVertexEndIndex += vertexStride * kVerticesPerGlyph;
1430 } 1430 }
1431 1431
1432 class TextBatch : public GrVertexBatch { 1432 class TextBatch : public GrVertexBatch {
1433 public: 1433 public:
1434 DEFINE_BATCH_CLASS_ID
1435
1436 typedef GrAtlasTextContext::DistanceAdjustTable DistanceAdjustTable; 1434 typedef GrAtlasTextContext::DistanceAdjustTable DistanceAdjustTable;
1437 typedef GrAtlasTextBlob Blob; 1435 typedef GrAtlasTextBlob Blob;
1438 typedef Blob::Run Run; 1436 typedef Blob::Run Run;
1439 typedef Run::SubRunInfo TextInfo; 1437 typedef Run::SubRunInfo TextInfo;
1440 struct Geometry { 1438 struct Geometry {
1441 Blob* fBlob; 1439 Blob* fBlob;
1442 int fRun; 1440 int fRun;
1443 int fSubRun; 1441 int fSubRun;
1444 GrColor fColor; 1442 GrColor fColor;
1445 SkScalar fTransX; 1443 SkScalar fTransX;
1446 SkScalar fTransY; 1444 SkScalar fTransY;
1447 }; 1445 };
1448 1446
1449 static TextBatch* CreateBitmap(GrMaskFormat maskFormat, int glyphCount, 1447 static TextBatch* CreateBitmap(GrMaskFormat maskFormat, int glyphCount,
1450 GrBatchFontCache* fontCache) { 1448 GrBatchFontCache* fontCache) {
1451 TextBatch* batch = new TextBatch; 1449 TextBatch* batch = new TextBatch;
1452 1450
1451 batch->initClassID<TextBatch>();
1453 batch->fFontCache = fontCache; 1452 batch->fFontCache = fontCache;
1454 switch (maskFormat) { 1453 switch (maskFormat) {
1455 case kA8_GrMaskFormat: 1454 case kA8_GrMaskFormat:
1456 batch->fMaskType = kGrayscaleCoverageMask_MaskType; 1455 batch->fMaskType = kGrayscaleCoverageMask_MaskType;
1457 break; 1456 break;
1458 case kA565_GrMaskFormat: 1457 case kA565_GrMaskFormat:
1459 batch->fMaskType = kLCDCoverageMask_MaskType; 1458 batch->fMaskType = kLCDCoverageMask_MaskType;
1460 break; 1459 break;
1461 case kARGB_GrMaskFormat: 1460 case kARGB_GrMaskFormat:
1462 batch->fMaskType = kColorBitmapMask_MaskType; 1461 batch->fMaskType = kColorBitmapMask_MaskType;
1463 break; 1462 break;
1464 } 1463 }
1465 batch->fBatch.fNumGlyphs = glyphCount; 1464 batch->fBatch.fNumGlyphs = glyphCount;
1466 batch->fGeoCount = 1; 1465 batch->fGeoCount = 1;
1467 batch->fFilteredColor = 0; 1466 batch->fFilteredColor = 0;
1468 batch->fFontCache = fontCache; 1467 batch->fFontCache = fontCache;
1469 batch->fUseBGR = false; 1468 batch->fUseBGR = false;
1470 return batch; 1469 return batch;
1471 } 1470 }
1472 1471
1473 static TextBatch* CreateDistanceField(int glyphCount, GrBatchFontCache* font Cache, 1472 static TextBatch* CreateDistanceField(int glyphCount, GrBatchFontCache* font Cache,
1474 const DistanceAdjustTable* distanceAdj ustTable, 1473 const DistanceAdjustTable* distanceAdj ustTable,
1475 SkColor filteredColor, bool isLCD, 1474 SkColor filteredColor, bool isLCD,
1476 bool useBGR) { 1475 bool useBGR) {
1477 TextBatch* batch = new TextBatch; 1476 TextBatch* batch = new TextBatch;
1478 1477 batch->initClassID<TextBatch>();
1479 batch->fFontCache = fontCache; 1478 batch->fFontCache = fontCache;
1480 batch->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistan ceField_MaskType; 1479 batch->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistan ceField_MaskType;
1481 batch->fDistanceAdjustTable.reset(SkRef(distanceAdjustTable)); 1480 batch->fDistanceAdjustTable.reset(SkRef(distanceAdjustTable));
1482 batch->fFilteredColor = filteredColor; 1481 batch->fFilteredColor = filteredColor;
1483 batch->fUseBGR = useBGR; 1482 batch->fUseBGR = useBGR;
1484 batch->fBatch.fNumGlyphs = glyphCount; 1483 batch->fBatch.fNumGlyphs = glyphCount;
1485 batch->fGeoCount = 1; 1484 batch->fGeoCount = 1;
1486 return batch; 1485 return batch;
1487 } 1486 }
1488 1487
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1776
1778 currVertex += byteCount; 1777 currVertex += byteCount;
1779 } 1778 }
1780 // Make sure to attach the last cache if applicable 1779 // Make sure to attach the last cache if applicable
1781 if (cache) { 1780 if (cache) {
1782 SkGlyphCache::AttachCache(cache); 1781 SkGlyphCache::AttachCache(cache);
1783 } 1782 }
1784 this->flush(target, &flushInfo); 1783 this->flush(target, &flushInfo);
1785 } 1784 }
1786 1785
1787 TextBatch() : INHERITED(ClassID()) {} // initialized in factory functions. 1786 TextBatch() {} // initialized in factory functions.
1788 1787
1789 ~TextBatch() { 1788 ~TextBatch() {
1790 for (int i = 0; i < fGeoCount; i++) { 1789 for (int i = 0; i < fGeoCount; i++) {
1791 fGeoData[i].fBlob->unref(); 1790 fGeoData[i].fBlob->unref();
1792 } 1791 }
1793 } 1792 }
1794 1793
1795 GrMaskFormat maskFormat() const { 1794 GrMaskFormat maskFormat() const {
1796 switch (fMaskType) { 1795 switch (fMaskType) {
1797 case kLCDCoverageMask_MaskType: 1796 case kLCDCoverageMask_MaskType:
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 kGrayscaleDistanceField_MaskType, 2037 kGrayscaleDistanceField_MaskType,
2039 kLCDDistanceField_MaskType, 2038 kLCDDistanceField_MaskType,
2040 } fMaskType; 2039 } fMaskType;
2041 bool fUseBGR; // fold this into the enum? 2040 bool fUseBGR; // fold this into the enum?
2042 2041
2043 GrBatchFontCache* fFontCache; 2042 GrBatchFontCache* fFontCache;
2044 2043
2045 // Distance field properties 2044 // Distance field properties
2046 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; 2045 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable;
2047 SkColor fFilteredColor; 2046 SkColor fFilteredColor;
2048
2049 typedef GrVertexBatch INHERITED;
2050 }; 2047 };
2051 2048
2052 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt, 2049 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
2053 const SkTextBlob::RunIterator& it, 2050 const SkTextBlob::RunIterator& it,
2054 const GrClip& clip, const SkPaint& skPa int, 2051 const GrClip& clip, const SkPaint& skPa int,
2055 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix, 2052 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix,
2056 const SkIRect& clipBounds, SkScalar x, SkScalar y) { 2053 const SkIRect& clipBounds, SkScalar x, SkScalar y) {
2057 SkPaint runPaint = skPaint; 2054 SkPaint runPaint = skPaint;
2058 2055
2059 size_t textLen = it.glyphCount() * sizeof(uint16_t); 2056 size_t textLen = it.glyphCount() * sizeof(uint16_t);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2279 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2283 static_cast<size_t>(textLen), 0, 0, noClip)); 2280 static_cast<size_t>(textLen), 0, 0, noClip));
2284 2281
2285 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2282 SkScalar transX = static_cast<SkScalar>(random->nextU());
2286 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2283 SkScalar transY = static_cast<SkScalar>(random->nextU());
2287 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2284 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2288 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2285 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2289 } 2286 }
2290 2287
2291 #endif 2288 #endif
OLDNEW
« no previous file with comments | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698