OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkPicture.h" |
| 9 #include "SkPictureAnalyzer.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 inline bool veto_predicate(uint32_t numSlowPaths) { |
| 14 return numSlowPaths > 5; |
| 15 } |
| 16 |
| 17 } // anonymous namespace |
| 18 |
| 19 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer() |
| 20 : fNumSlowPaths(0) { } |
| 21 |
| 22 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture) |
| 23 : SkPictureGpuAnalyzer() { |
| 24 this->analyze(picture.get()); |
| 25 } |
| 26 |
| 27 void SkPictureGpuAnalyzer::analyze(const SkPicture* picture) { |
| 28 if (!picture || veto_predicate(fNumSlowPaths)) { |
| 29 return; |
| 30 } |
| 31 |
| 32 fNumSlowPaths += picture->numSlowPaths(); |
| 33 } |
| 34 |
| 35 void SkPictureGpuAnalyzer::reset() { |
| 36 fNumSlowPaths = 0; |
| 37 } |
| 38 |
| 39 bool SkPictureGpuAnalyzer::suitableForGpuRasterization(GrContext*, const char**
whyNot) const { |
| 40 if(veto_predicate(fNumSlowPaths)) { |
| 41 if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed).
"; } |
| 42 return false; |
| 43 } |
| 44 return true; |
| 45 } |
OLD | NEW |