aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-01-30 09:59:10 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-30 09:59:10 -0800
commit2279325d539700ee3da29d6e874b3b3ce1dcf49c (patch)
treefa68207d94b4919c1759578a5d5192786d83c6d6 /include
parentad38ed6003ad89a21e40d76987db4bba7d42f3d0 (diff)
added support for PLS path rendering
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrCaps.h20
-rw-r--r--include/gpu/GrConfig.h8
-rw-r--r--include/gpu/GrShaderVar.h10
-rw-r--r--include/gpu/GrTypesPriv.h66
-rw-r--r--include/gpu/GrXferProcessor.h14
-rw-r--r--include/gpu/effects/GrCoverageSetOpXP.h6
-rw-r--r--include/gpu/effects/GrPorterDuffXferProcessor.h6
7 files changed, 101 insertions, 29 deletions
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index e2e59c30a4..05da8d7cad 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -81,6 +81,24 @@ public:
*/
bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
+ /**
+ * PLS storage size in bytes (0 when not supported). The PLS spec defines a minimum size of 16
+ * bytes whenever PLS is supported.
+ */
+ int pixelLocalStorageSize() const { return fPixelLocalStorageSize; }
+
+ /**
+ * True if this context supports the necessary extensions and features to enable the PLS path
+ * renderer.
+ */
+ bool plsPathRenderingSupport() const {
+#if GR_ENABLE_PLS_PATH_RENDERING
+ return fPLSPathRenderingSupport;
+#else
+ return false;
+#endif
+ }
+
protected:
/** Subclasses must call this after initialization in order to apply caps overrides requested by
the client. Note that overrides will only reduce the caps never expand them. */
@@ -94,6 +112,8 @@ protected:
bool fShaderPrecisionVaries;
PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
+ int fPixelLocalStorageSize;
+ bool fPLSPathRenderingSupport;
private:
virtual void onApplyOptionsOverrides(const GrContextOptions&) {};
diff --git a/include/gpu/GrConfig.h b/include/gpu/GrConfig.h
index 34666857e5..202887ee5d 100644
--- a/include/gpu/GrConfig.h
+++ b/include/gpu/GrConfig.h
@@ -193,4 +193,12 @@ typedef unsigned __int64 uint64_t;
#if !defined(GR_BATCH_DEBUGGING_OUTPUT)
#define GR_BATCH_DEBUGGING_OUTPUT 0
#endif
+
+/**
+ * Set to 1 to enable pixel local storage path rendering on supported devices.
+ */
+#if !defined(GR_ENABLE_PLS_PATH_RENDERING)
+ #define GR_ENABLE_PLS_PATH_RENDERING 0
+#endif
+
#endif
diff --git a/include/gpu/GrShaderVar.h b/include/gpu/GrShaderVar.h
index 68ce34b8ef..3f56eaf70a 100644
--- a/include/gpu/GrShaderVar.h
+++ b/include/gpu/GrShaderVar.h
@@ -51,7 +51,7 @@ public:
, fName(name)
, fCount(arrayCount)
, fPrecision(precision) {
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kVoid_GrSLType != type);
}
@@ -62,7 +62,7 @@ public:
, fName(name)
, fCount(arrayCount)
, fPrecision(precision) {
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kVoid_GrSLType != type);
}
@@ -73,7 +73,7 @@ public:
, fName(name)
, fCount(arrayCount)
, fPrecision(precision) {
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
SkASSERT(kVoid_GrSLType != type);
}
@@ -91,7 +91,7 @@ public:
GrSLPrecision precision = kDefault_GrSLPrecision,
int count = kNonArray) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
@@ -105,7 +105,7 @@ public:
GrSLPrecision precision = kDefault_GrSLPrecision,
int count = kNonArray) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index c46e25bd0d..bc107b5cf5 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -27,8 +27,10 @@ enum GrSLType {
kSampler2D_GrSLType,
kSamplerExternal_GrSLType,
kSampler2DRect_GrSLType,
+ kBool_GrSLType,
+ kInt_GrSLType,
- kLast_GrSLType = kSampler2DRect_GrSLType
+ kLast_GrSLType = kInt_GrSLType
};
static const int kGrSLTypeCount = kLast_GrSLType + 1;
@@ -65,7 +67,7 @@ static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
*/
static inline int GrSLTypeVectorCount(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
- static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1 };
+ static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1 };
return kCounts[type];
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
@@ -78,6 +80,8 @@ static inline int GrSLTypeVectorCount(GrSLType type) {
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
+ GR_STATIC_ASSERT(10 == kBool_GrSLType);
+ GR_STATIC_ASSERT(11 == kInt_GrSLType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
}
@@ -93,10 +97,10 @@ static inline GrSLType GrSLFloatVectorType(int count) {
GR_STATIC_ASSERT(kVec4f_GrSLType == 4);
}
-/** Is the shading language type floating point (or vector/matrix of fp)? */
+/** Is the shading language type float (including vectors/matrices)? */
static inline bool GrSLTypeIsFloatType(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
- return type >= 1 && type <= 6;
+ return (type >= 1 && type <= 6);
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
GR_STATIC_ASSERT(1 == kFloat_GrSLType);
@@ -108,7 +112,34 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) {
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(10 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(10 == kBool_GrSLType);
+ GR_STATIC_ASSERT(11 == kInt_GrSLType);
+ GR_STATIC_ASSERT(12 == kGrSLTypeCount);
+}
+
+/** Is the shading language type integral (including vectors/matrices)? */
+static inline bool GrSLTypeIsIntType(GrSLType type) {
+ SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
+ return type == kInt_GrSLType;
+
+ GR_STATIC_ASSERT(0 == kVoid_GrSLType);
+ GR_STATIC_ASSERT(1 == kFloat_GrSLType);
+ GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
+ GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
+ GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
+ GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
+ GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
+ GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
+ GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
+ GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
+ GR_STATIC_ASSERT(10 == kBool_GrSLType);
+ GR_STATIC_ASSERT(11 == kInt_GrSLType);
+ GR_STATIC_ASSERT(12 == kGrSLTypeCount);
+}
+
+/** Is the shading language type numeric (including vectors/matrices)? */
+static inline bool GrSLTypeIsNumeric(GrSLType type) {
+ return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type);
}
/** Returns the size in bytes for floating point GrSLTypes. For non floating point type returns 0 */
@@ -123,8 +154,10 @@ static inline size_t GrSLTypeSize(GrSLType type) {
9 * sizeof(float), // kMat33f_GrSLType
16 * sizeof(float), // kMat44f_GrSLType
0, // kSampler2D_GrSLType
- 0, // kSamplerExternal_GrSLType
- 0 // kSampler2DRect_GrSLType
+ 0, // kSamplerExternal_GrSLType
+ 0, // kSampler2DRect_GrSLType
+ 0, // kBool_GrSLType
+ 0, // kInt_GrSLType
};
return kSizes[type];
@@ -138,7 +171,9 @@ static inline size_t GrSLTypeSize(GrSLType type) {
GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(10 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(10 == kBool_GrSLType);
+ GR_STATIC_ASSERT(11 == kInt_GrSLType);
+ GR_STATIC_ASSERT(12 == kGrSLTypeCount);
}
static inline bool GrSLTypeIsSamplerType(GrSLType type) {
@@ -165,8 +200,10 @@ enum GrVertexAttribType {
kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors
kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates
+
+ kInt_GrVertexAttribType,
- kLast_GrVertexAttribType = kVec2s_GrVertexAttribType
+ kLast_GrVertexAttribType = kInt_GrVertexAttribType
};
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
@@ -174,8 +211,7 @@ static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
* Returns the vector size of the type.
*/
static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
- SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
- static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2 };
+ static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1 };
return kCounts[type];
GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
@@ -185,6 +221,7 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
+ GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount);
}
@@ -192,7 +229,6 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
* Returns the size of the attrib type in bytes.
*/
static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
- SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
static const size_t kSizes[] = {
sizeof(float), // kFloat_GrVertexAttribType
2*sizeof(float), // kVec2f_GrVertexAttribType
@@ -200,7 +236,8 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
4*sizeof(float), // kVec4f_GrVertexAttribType
1*sizeof(char), // kUByte_GrVertexAttribType
4*sizeof(char), // kVec4ub_GrVertexAttribType
- 2*sizeof(int16_t) // kVec2s_GrVertexAttribType
+ 2*sizeof(int16_t), // kVec2s_GrVertexAttribType
+ sizeof(int32_t) // kInt_GrVertexAttribType
};
return kSizes[type];
@@ -211,6 +248,7 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
+ GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount);
}
@@ -233,6 +271,8 @@ static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
case kVec4ub_GrVertexAttribType:
case kVec4f_GrVertexAttribType:
return kVec4f_GrSLType;
+ case kInt_GrVertexAttribType:
+ return kInt_GrSLType;
}
}
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index ce26709d9a..3a698143c3 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -355,15 +355,19 @@ private:
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples,
const DstTexture*) const = 0;
+
+ virtual bool onIsEqual(const GrXPFactory&) const = 0;
+
+ bool willReadDstColor(const GrCaps& caps,
+ const GrPipelineOptimizations& optimizations,
+ bool hasMixedSamples) const;
/**
* Returns true if the XP generated by this factory will explicitly read dst in the fragment
* shader.
*/
- virtual bool willReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const = 0;
-
- virtual bool onIsEqual(const GrXPFactory&) const = 0;
+ virtual bool onWillReadDstColor(const GrCaps& caps,
+ const GrPipelineOptimizations& optimizations,
+ bool hasMixedSamples) const = 0;
static uint32_t GenClassID() {
// fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The
diff --git a/include/gpu/effects/GrCoverageSetOpXP.h b/include/gpu/effects/GrCoverageSetOpXP.h
index 097a890d56..42ac6ac528 100644
--- a/include/gpu/effects/GrCoverageSetOpXP.h
+++ b/include/gpu/effects/GrCoverageSetOpXP.h
@@ -34,9 +34,9 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool willReadDstColor(const GrCaps& /*caps*/,
- const GrPipelineOptimizations& /*optimizations*/,
- bool /*hasMixedSamples*/) const override {
+ bool onWillReadDstColor(const GrCaps& /*caps*/,
+ const GrPipelineOptimizations& /*optimizations*/,
+ bool /*hasMixedSamples*/) const override {
return false;
}
diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h
index 457c6eabc8..865ef44253 100644
--- a/include/gpu/effects/GrPorterDuffXferProcessor.h
+++ b/include/gpu/effects/GrPorterDuffXferProcessor.h
@@ -60,9 +60,9 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool willReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override;
+ bool onWillReadDstColor(const GrCaps& caps,
+ const GrPipelineOptimizations& optimizations,
+ bool hasMixedSamples) const override;
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();