aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrStyle.cpp
blob: 40a148bb4a9c6e88063d064aa3232ef6fda50202 (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
/*
 * 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 "GrStyle.h"

void GrStyle::initPathEffect(SkPathEffect* pe) {
    if (!pe) {
        fDashInfo.fType = SkPathEffect::kNone_DashType;
        return;
    }
    SkPathEffect::DashInfo info;
    if (SkPathEffect::kDash_DashType == pe->asADash(&info)) {
        if (fStrokeRec.getStyle() == SkStrokeRec::kFill_Style) {
            fPathEffect.reset(nullptr);
        } else {
            fPathEffect.reset(SkSafeRef(pe));
            fDashInfo.fType = SkPathEffect::kDash_DashType;
            fDashInfo.fIntervals.reset(info.fCount);
            fDashInfo.fPhase = info.fPhase;
            info.fIntervals = fDashInfo.fIntervals.get();
            pe->asADash(&info);
            return;
        }
    } else {
        fPathEffect.reset(SkSafeRef(pe));
    }
    fDashInfo.fType = SkPathEffect::kNone_DashType;
    fDashInfo.fIntervals.reset(0);
}