Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/core/SkAutoBlitterChoose.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2017 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
#ifndef SkAutoBlitterChoose_DEFINED
9
#define SkAutoBlitterChoose_DEFINED
10
11
#include "include/private/SkMacros.h"
12
#include "src/core/SkArenaAlloc.h"
13
#include "src/core/SkBlitter.h"
14
#include "src/core/SkDraw.h"
15
#include "src/core/SkRasterClip.h"
16
17
class SkMatrix;
18
class SkPaint;
19
class SkPixmap;
20
21
class SkAutoBlitterChoose : SkNoncopyable {
22
public:
23
269k
    SkAutoBlitterChoose() {}
24
    SkAutoBlitterChoose(const SkDraw& draw, const SkMatrixProvider* matrixProvider,
25
76.1k
                        const SkPaint& paint, bool drawCoverage = false) {
26
76.1k
        this->choose(draw, matrixProvider, paint, drawCoverage);
27
76.1k
    }
28
29
0
    SkBlitter*  operator->() { return fBlitter; }
30
76.1k
    SkBlitter*  get() const { return fBlitter; }
31
32
    SkBlitter* choose(const SkDraw& draw, const SkMatrixProvider* matrixProvider,
33
345k
                      const SkPaint& paint, bool drawCoverage = false) {
34
345k
        SkASSERT(!fBlitter);
35
345k
        if (!matrixProvider) {
36
332k
            matrixProvider = draw.fMatrixProvider;
37
332k
        }
38
345k
        fBlitter = SkBlitter::Choose(draw.fDst, *matrixProvider, paint, &fAlloc, drawCoverage,
39
345k
                                     draw.fRC->clipShader());
40
41
345k
        if (draw.fCoverage) {
42
            // hmm, why can't choose ignore the paint if drawCoverage is true?
43
0
            SkBlitter* coverageBlitter =
44
0
                    SkBlitter::Choose(*draw.fCoverage, *matrixProvider, SkPaint(), &fAlloc, true,
45
0
                                      draw.fRC->clipShader());
46
0
            fBlitter = fAlloc.make<SkPairBlitter>(fBlitter, coverageBlitter);
47
0
        }
48
345k
        return fBlitter;
49
345k
    }
50
51
private:
52
    // Owned by fAlloc, which will handle the delete.
53
    SkBlitter* fBlitter = nullptr;
54
55
    SkSTArenaAlloc<kSkBlitterContextSize> fAlloc;
56
};
57
58
#endif