skia2/src/sksl/ir/SkSLFieldAccess.h
Ethan Nicholas 0054311bf3 Re-re-land "added GrSkSLFP and converted DitherEffect to use it"
This reverts commit 6c48e4d11c.

Bug: skia:
Change-Id: I7ee78990fc30eec545d1856e59eb6e0573089426
Reviewed-on: https://skia-review.googlesource.com/144348
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-07-31 15:18:03 +00:00

57 lines
1.6 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKSL_FIELDACCESS
#define SKSL_FIELDACCESS
#include "SkSLExpression.h"
#include "SkSLUtil.h"
namespace SkSL {
/**
* An expression which extracts a field from a struct, as in 'foo.bar'.
*/
struct FieldAccess : public Expression {
enum OwnerKind {
kDefault_OwnerKind,
// this field access is to a field of an anonymous interface block (and thus, the field name
// is actually in global scope, so only the field name needs to be written in GLSL)
kAnonymousInterfaceBlock_OwnerKind
};
FieldAccess(std::unique_ptr<Expression> base, int fieldIndex,
OwnerKind ownerKind = kDefault_OwnerKind)
: INHERITED(base->fOffset, kFieldAccess_Kind, *base->fType.fields()[fieldIndex].fType)
, fBase(std::move(base))
, fFieldIndex(fieldIndex)
, fOwnerKind(ownerKind) {}
bool hasSideEffects() const override {
return fBase->hasSideEffects();
}
std::unique_ptr<Expression> clone() const override {
return std::unique_ptr<Expression>(new FieldAccess(fBase->clone(), fFieldIndex,
fOwnerKind));
}
String description() const override {
return fBase->description() + "." + fBase->fType.fields()[fFieldIndex].fName;
}
std::unique_ptr<Expression> fBase;
const int fFieldIndex;
const OwnerKind fOwnerKind;
typedef Expression INHERITED;
};
} // namespace
#endif