| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 dfpr->fPathList.remove(pathData); | 55 dfpr->fPathList.remove(pathData); |
| 56 delete pathData; | 56 delete pathData; |
| 57 #ifdef DF_PATH_TRACKING | 57 #ifdef DF_PATH_TRACKING |
| 58 ++g_NumFreedPaths; | 58 ++g_NumFreedPaths; |
| 59 #endif | 59 #endif |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 65 GrAADistanceFieldPathRenderer::GrAADistanceFieldPathRenderer() : fAtlas(NULL) {} | 65 GrAADistanceFieldPathRenderer::GrAADistanceFieldPathRenderer() : fAtlas(nullptr)
{} |
| 66 | 66 |
| 67 GrAADistanceFieldPathRenderer::~GrAADistanceFieldPathRenderer() { | 67 GrAADistanceFieldPathRenderer::~GrAADistanceFieldPathRenderer() { |
| 68 PathDataList::Iter iter; | 68 PathDataList::Iter iter; |
| 69 iter.init(fPathList, PathDataList::Iter::kHead_IterStart); | 69 iter.init(fPathList, PathDataList::Iter::kHead_IterStart); |
| 70 PathData* pathData; | 70 PathData* pathData; |
| 71 while ((pathData = iter.get())) { | 71 while ((pathData = iter.get())) { |
| 72 iter.next(); | 72 iter.next(); |
| 73 fPathList.remove(pathData); | 73 fPathList.remove(pathData); |
| 74 delete pathData; | 74 delete pathData; |
| 75 } | 75 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } else if (size <= kMediumMIP) { | 219 } else if (size <= kMediumMIP) { |
| 220 desiredDimension = kMediumMIP; | 220 desiredDimension = kMediumMIP; |
| 221 } else { | 221 } else { |
| 222 desiredDimension = kLargeMIP; | 222 desiredDimension = kLargeMIP; |
| 223 } | 223 } |
| 224 | 224 |
| 225 // check to see if path is cached | 225 // check to see if path is cached |
| 226 // TODO: handle stroked vs. filled version of same path | 226 // TODO: handle stroked vs. filled version of same path |
| 227 PathData::Key key = { args.fPath.getGenerationID(), desiredDimension
}; | 227 PathData::Key key = { args.fPath.getGenerationID(), desiredDimension
}; |
| 228 args.fPathData = fPathCache->find(key); | 228 args.fPathData = fPathCache->find(key); |
| 229 if (NULL == args.fPathData || !atlas->hasID(args.fPathData->fID)) { | 229 if (nullptr == args.fPathData || !atlas->hasID(args.fPathData->fID))
{ |
| 230 // Remove the stale cache entry | 230 // Remove the stale cache entry |
| 231 if (args.fPathData) { | 231 if (args.fPathData) { |
| 232 fPathCache->remove(args.fPathData->fKey); | 232 fPathCache->remove(args.fPathData->fKey); |
| 233 fPathList->remove(args.fPathData); | 233 fPathList->remove(args.fPathData); |
| 234 delete args.fPathData; | 234 delete args.fPathData; |
| 235 } | 235 } |
| 236 SkScalar scale = desiredDimension/maxDim; | 236 SkScalar scale = desiredDimension/maxDim; |
| 237 args.fPathData = new PathData; | 237 args.fPathData = new PathData; |
| 238 if (!this->addPathToAtlas(target, | 238 if (!this->addPathToAtlas(target, |
| 239 dfProcessor, | 239 dfProcessor, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 274 |
| 275 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 275 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 276 | 276 |
| 277 AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMa
trix& viewMatrix, | 277 AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMa
trix& viewMatrix, |
| 278 GrBatchAtlas* atlas, | 278 GrBatchAtlas* atlas, |
| 279 PathCache* pathCache, PathDataList* pathList) { | 279 PathCache* pathCache, PathDataList* pathList) { |
| 280 this->initClassID<AADistanceFieldPathBatch>(); | 280 this->initClassID<AADistanceFieldPathBatch>(); |
| 281 fBatch.fColor = color; | 281 fBatch.fColor = color; |
| 282 fBatch.fViewMatrix = viewMatrix; | 282 fBatch.fViewMatrix = viewMatrix; |
| 283 fGeoData.push_back(geometry); | 283 fGeoData.push_back(geometry); |
| 284 fGeoData.back().fPathData = NULL; | 284 fGeoData.back().fPathData = nullptr; |
| 285 | 285 |
| 286 fAtlas = atlas; | 286 fAtlas = atlas; |
| 287 fPathCache = pathCache; | 287 fPathCache = pathCache; |
| 288 fPathList = pathList; | 288 fPathList = pathList; |
| 289 | 289 |
| 290 // Compute bounds | 290 // Compute bounds |
| 291 fBounds = geometry.fPath.getBounds(); | 291 fBounds = geometry.fPath.getBounds(); |
| 292 viewMatrix.mapRect(&fBounds); | 292 viewMatrix.mapRect(&fBounds); |
| 293 } | 293 } |
| 294 | 294 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 551 } |
| 552 | 552 |
| 553 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 553 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 554 | 554 |
| 555 #ifdef GR_TEST_UTILS | 555 #ifdef GR_TEST_UTILS |
| 556 | 556 |
| 557 struct PathTestStruct { | 557 struct PathTestStruct { |
| 558 typedef GrAADistanceFieldPathRenderer::PathCache PathCache; | 558 typedef GrAADistanceFieldPathRenderer::PathCache PathCache; |
| 559 typedef GrAADistanceFieldPathRenderer::PathData PathData; | 559 typedef GrAADistanceFieldPathRenderer::PathData PathData; |
| 560 typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList; | 560 typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList; |
| 561 PathTestStruct() : fContextID(SK_InvalidGenID), fAtlas(NULL) {} | 561 PathTestStruct() : fContextID(SK_InvalidGenID), fAtlas(nullptr) {} |
| 562 ~PathTestStruct() { this->reset(); } | 562 ~PathTestStruct() { this->reset(); } |
| 563 | 563 |
| 564 void reset() { | 564 void reset() { |
| 565 PathDataList::Iter iter; | 565 PathDataList::Iter iter; |
| 566 iter.init(fPathList, PathDataList::Iter::kHead_IterStart); | 566 iter.init(fPathList, PathDataList::Iter::kHead_IterStart); |
| 567 PathData* pathData; | 567 PathData* pathData; |
| 568 while ((pathData = iter.get())) { | 568 while ((pathData = iter.get())) { |
| 569 iter.next(); | 569 iter.next(); |
| 570 fPathList.remove(pathData); | 570 fPathList.remove(pathData); |
| 571 delete pathData; | 571 delete pathData; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 geometry.fPath = GrTest::TestPath(random); | 617 geometry.fPath = GrTest::TestPath(random); |
| 618 geometry.fAntiAlias = random->nextBool(); | 618 geometry.fAntiAlias = random->nextBool(); |
| 619 | 619 |
| 620 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, | 620 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, |
| 621 gTestStruct.fAtlas, | 621 gTestStruct.fAtlas, |
| 622 &gTestStruct.fPathCache, | 622 &gTestStruct.fPathCache, |
| 623 &gTestStruct.fPathList); | 623 &gTestStruct.fPathList); |
| 624 } | 624 } |
| 625 | 625 |
| 626 #endif | 626 #endif |
| OLD | NEW |