aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProcOptInfo.cpp
blob: 92e6838c31f29be266c0b61ce151cca967eeade5 (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
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrProcOptInfo.h"
#include "GrGeometryProcessor.h"
#include "ops/GrDrawOp.h"

void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt) {
    for (int i = 0; i < cnt; ++i) {
        bool knowCurrentOutput = fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited;
        if (!knowCurrentOutput && !fAllProcessorsModulatePremul && !fIsOpaque) {
            fTotalProcessorsVisited += cnt - i;
            return;
        }
        const GrFragmentProcessor* fp = processors[i];
        if (knowCurrentOutput && fp->hasConstantOutputForConstantInput(fLastKnownOutputColor,
                                                                      &fLastKnownOutputColor)) {
            ++fProcessorsVisitedWithKnownOutput;
            fIsOpaque = fLastKnownOutputColor.isOpaque();
        } else if (fIsOpaque && !fp->preservesOpaqueInput()) {
            fIsOpaque = false;
        }
        if (fAllProcessorsModulatePremul && !fp->modulatesInput()) {
            fAllProcessorsModulatePremul = false;
        }
        ++fTotalProcessorsVisited;
    }
}