blob: 62c27e15a1a27cc8ee252f7f0e390f9645888fcb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkPath.h"
#include "SkPicture.h"
#include "SkPictureAnalyzer.h"
#include "SkPictureCommon.h"
#include "SkRecords.h"
#if SK_SUPPORT_GPU
namespace {
inline bool veto_predicate(uint32_t numSlowPaths) {
return numSlowPaths > 5;
}
} // anonymous namespace
SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> /* unused ATM */)
: fNumSlowPaths(0) { }
SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture,
sk_sp<GrContextThreadSafeProxy> ctx)
: SkPictureGpuAnalyzer(std::move(ctx)) {
this->analyzePicture(picture.get());
}
void SkPictureGpuAnalyzer::analyzePicture(const SkPicture* picture) {
if (!picture) {
return;
}
fNumSlowPaths += picture->numSlowPaths();
}
void SkPictureGpuAnalyzer::analyzeClipPath(const SkPath& path, SkClipOp op, bool doAntiAlias) {
const SkRecords::ClipPath clipOp = {
SkIRect::MakeEmpty(), // Willie don't care.
path,
SkRecords::ClipOpAndAA(op, doAntiAlias)
};
SkPathCounter counter;
counter(clipOp);
fNumSlowPaths += counter.fNumSlowPathsAndDashEffects;
}
void SkPictureGpuAnalyzer::reset() {
fNumSlowPaths = 0;
}
bool SkPictureGpuAnalyzer::suitableForGpuRasterization(const char** whyNot) const {
if(veto_predicate(fNumSlowPaths)) {
if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed)."; }
return false;
}
return true;
}
#endif // SK_SUPPORT_GPU
|