Remove hacks for UShort2 texture coords
Plumb GPU type down for binding of vertex attributes in GL. Use that to select between float and int versions of VertexAttribPointer. For client code that was relying on the strange behavior of UShort2, use shader caps to pick the appropriate GrSLType. Bug: skia: Change-Id: If52ea49e0a5667246687e90e088d0823dbedb921 Reviewed-on: https://skia-review.googlesource.com/155401 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
c766370d86
commit
4a3f5c8141
@ -8,6 +8,8 @@
|
|||||||
#include "GrBitmapTextGeoProc.h"
|
#include "GrBitmapTextGeoProc.h"
|
||||||
|
|
||||||
#include "GrAtlasedShaderHelpers.h"
|
#include "GrAtlasedShaderHelpers.h"
|
||||||
|
#include "GrCaps.h"
|
||||||
|
#include "GrShaderCaps.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||||
@ -119,7 +121,8 @@ private:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color,
|
GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps,
|
||||||
|
GrColor color,
|
||||||
const sk_sp<GrTextureProxy>* proxies,
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& params, GrMaskFormat format,
|
const GrSamplerState& params, GrMaskFormat format,
|
||||||
@ -136,8 +139,9 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color,
|
|||||||
} else {
|
} else {
|
||||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||||
}
|
}
|
||||||
fInTextureCoords =
|
|
||||||
{"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
|
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
|
||||||
|
caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType };
|
||||||
int cnt = 2;
|
int cnt = 2;
|
||||||
|
|
||||||
bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat ||
|
bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat ||
|
||||||
@ -228,8 +232,8 @@ sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), proxies, 1, samplerState,
|
return GrBitmapTextGeoProc::Make(*d->caps()->shaderCaps(), GrRandomColor(d->fRandom), proxies,
|
||||||
format, GrTest::TestMatrix(d->fRandom),
|
1, samplerState, format, GrTest::TestMatrix(d->fRandom),
|
||||||
d->fRandom->nextBool());
|
d->fRandom->nextBool());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,13 +23,13 @@ class GrBitmapTextGeoProc : public GrGeometryProcessor {
|
|||||||
public:
|
public:
|
||||||
static constexpr int kMaxTextures = 4;
|
static constexpr int kMaxTextures = 4;
|
||||||
|
|
||||||
static sk_sp<GrGeometryProcessor> Make(GrColor color,
|
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps, GrColor color,
|
||||||
const sk_sp<GrTextureProxy>* proxies,
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& p, GrMaskFormat format,
|
const GrSamplerState& p, GrMaskFormat format,
|
||||||
const SkMatrix& localMatrix, bool usesW) {
|
const SkMatrix& localMatrix, bool usesW) {
|
||||||
return sk_sp<GrGeometryProcessor>(
|
return sk_sp<GrGeometryProcessor>(
|
||||||
new GrBitmapTextGeoProc(color, proxies, numActiveProxies, p, format,
|
new GrBitmapTextGeoProc(caps, color, proxies, numActiveProxies, p, format,
|
||||||
localMatrix, usesW));
|
localMatrix, usesW));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ public:
|
|||||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
|
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrBitmapTextGeoProc(GrColor, const sk_sp<GrTextureProxy>* proxies, int numProxies,
|
GrBitmapTextGeoProc(const GrShaderCaps&, GrColor, const sk_sp<GrTextureProxy>* proxies,
|
||||||
const GrSamplerState& params, GrMaskFormat format,
|
int numProxies, const GrSamplerState& params, GrMaskFormat format,
|
||||||
const SkMatrix& localMatrix, bool usesW);
|
const SkMatrix& localMatrix, bool usesW);
|
||||||
|
|
||||||
const Attribute& onVertexAttribute(int i) const override;
|
const Attribute& onVertexAttribute(int i) const override;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "GrDistanceFieldGeoProc.h"
|
#include "GrDistanceFieldGeoProc.h"
|
||||||
#include "GrAtlasedShaderHelpers.h"
|
#include "GrAtlasedShaderHelpers.h"
|
||||||
|
#include "GrCaps.h"
|
||||||
|
#include "GrShaderCaps.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "SkDistanceFieldGen.h"
|
#include "SkDistanceFieldGen.h"
|
||||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||||
@ -205,9 +207,9 @@ private:
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldA8TextGeoProc::kInColor;
|
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldA8TextGeoProc::kInColor;
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldA8TextGeoProc::kInTextureCoords;
|
|
||||||
|
|
||||||
GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const sk_sp<GrTextureProxy>* proxies,
|
GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numProxies,
|
int numProxies,
|
||||||
const GrSamplerState& params,
|
const GrSamplerState& params,
|
||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
@ -230,6 +232,8 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const sk_sp<GrTexture
|
|||||||
} else {
|
} else {
|
||||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||||
}
|
}
|
||||||
|
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
|
||||||
|
caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType};
|
||||||
this->setVertexAttributeCnt(3);
|
this->setVertexAttributeCnt(3);
|
||||||
|
|
||||||
if (numProxies) {
|
if (numProxies) {
|
||||||
@ -302,7 +306,8 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
|
|||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
float lum = d->fRandom->nextF();
|
float lum = d->fRandom->nextF();
|
||||||
#endif
|
#endif
|
||||||
return GrDistanceFieldA8TextGeoProc::Make(proxies, 1,
|
return GrDistanceFieldA8TextGeoProc::Make(*d->caps()->shaderCaps(),
|
||||||
|
proxies, 1,
|
||||||
samplerState,
|
samplerState,
|
||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
lum,
|
lum,
|
||||||
@ -506,9 +511,9 @@ private:
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInPosition;
|
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInPosition;
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInColor;
|
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInColor;
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInTextureCoords;
|
|
||||||
|
|
||||||
GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const SkMatrix& matrix,
|
GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
|
||||||
|
const SkMatrix& matrix,
|
||||||
const sk_sp<GrTextureProxy>* proxies,
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numProxies,
|
int numProxies,
|
||||||
const GrSamplerState& params,
|
const GrSamplerState& params,
|
||||||
@ -519,6 +524,8 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const SkMatrix& matrix,
|
|||||||
SkASSERT(numProxies <= kMaxTextures);
|
SkASSERT(numProxies <= kMaxTextures);
|
||||||
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
|
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
|
||||||
|
|
||||||
|
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
|
||||||
|
caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType};
|
||||||
this->setVertexAttributeCnt(3);
|
this->setVertexAttributeCnt(3);
|
||||||
|
|
||||||
if (numProxies) {
|
if (numProxies) {
|
||||||
@ -564,7 +571,7 @@ GrDistanceFieldPathGeoProc::createGLSLInstance(const GrShaderCaps&) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GrPrimitiveProcessor::Attribute& GrDistanceFieldPathGeoProc::onVertexAttribute(int i) const {
|
const GrPrimitiveProcessor::Attribute& GrDistanceFieldPathGeoProc::onVertexAttribute(int i) const {
|
||||||
return IthAttribute(i, kInPosition, kInColor, kInTextureCoords);
|
return IthAttribute(i, kInPosition, kInColor, fInTextureCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -594,7 +601,8 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
|
|||||||
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
|
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GrDistanceFieldPathGeoProc::Make(GrTest::TestMatrix(d->fRandom),
|
return GrDistanceFieldPathGeoProc::Make(*d->caps()->shaderCaps(),
|
||||||
|
GrTest::TestMatrix(d->fRandom),
|
||||||
proxies, 1,
|
proxies, 1,
|
||||||
samplerState,
|
samplerState,
|
||||||
flags);
|
flags);
|
||||||
@ -821,9 +829,9 @@ private:
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldLCDTextGeoProc::kInColor;
|
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldLCDTextGeoProc::kInColor;
|
||||||
constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldLCDTextGeoProc::kInTextureCoords;
|
|
||||||
|
|
||||||
GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const sk_sp<GrTextureProxy>* proxies,
|
GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numProxies,
|
int numProxies,
|
||||||
const GrSamplerState& params,
|
const GrSamplerState& params,
|
||||||
DistanceAdjust distanceAdjust,
|
DistanceAdjust distanceAdjust,
|
||||||
@ -841,6 +849,8 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const sk_sp<GrTextu
|
|||||||
} else {
|
} else {
|
||||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||||
}
|
}
|
||||||
|
fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
|
||||||
|
caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType};
|
||||||
this->setVertexAttributeCnt(3);
|
this->setVertexAttributeCnt(3);
|
||||||
|
|
||||||
if (numProxies) {
|
if (numProxies) {
|
||||||
@ -886,7 +896,7 @@ GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons
|
|||||||
|
|
||||||
const GrPrimitiveProcessor::Attribute& GrDistanceFieldLCDTextGeoProc::onVertexAttribute(
|
const GrPrimitiveProcessor::Attribute& GrDistanceFieldLCDTextGeoProc::onVertexAttribute(
|
||||||
int i) const {
|
int i) const {
|
||||||
return IthAttribute(i, fInPosition, kInColor, kInTextureCoords);
|
return IthAttribute(i, fInPosition, kInColor, fInTextureCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -917,6 +927,7 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
|
|||||||
}
|
}
|
||||||
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
|
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
|
||||||
SkMatrix localMatrix = GrTest::TestMatrix(d->fRandom);
|
SkMatrix localMatrix = GrTest::TestMatrix(d->fRandom);
|
||||||
return GrDistanceFieldLCDTextGeoProc::Make(proxies, 1, samplerState, wa, flags, localMatrix);
|
return GrDistanceFieldLCDTextGeoProc::Make(*d->caps()->shaderCaps(), proxies, 1, samplerState,
|
||||||
|
wa, flags, localMatrix);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -57,20 +57,22 @@ public:
|
|||||||
|
|
||||||
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
static sk_sp<GrGeometryProcessor> Make(const sk_sp<GrTextureProxy>* proxies,
|
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& params, float lum, uint32_t flags,
|
const GrSamplerState& params, float lum, uint32_t flags,
|
||||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||||
return sk_sp<GrGeometryProcessor>(new GrDistanceFieldA8TextGeoProc(
|
return sk_sp<GrGeometryProcessor>(new GrDistanceFieldA8TextGeoProc(
|
||||||
proxies, numActiveProxies, params, lum, flags, localMatrixIfUsesLocalCoords));
|
caps, proxies, numActiveProxies, params, lum, flags, localMatrixIfUsesLocalCoords));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static sk_sp<GrGeometryProcessor> Make(const sk_sp<GrTextureProxy>* proxies,
|
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& params, uint32_t flags,
|
const GrSamplerState& params, uint32_t flags,
|
||||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||||
return sk_sp<GrGeometryProcessor>(new GrDistanceFieldA8TextGeoProc(
|
return sk_sp<GrGeometryProcessor>(new GrDistanceFieldA8TextGeoProc(
|
||||||
proxies, numActiveProxies, params, flags, localMatrixIfUsesLocalCoords));
|
caps, proxies, numActiveProxies, params, flags, localMatrixIfUsesLocalCoords));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ public:
|
|||||||
|
|
||||||
const Attribute& inPosition() const { return fInPosition; }
|
const Attribute& inPosition() const { return fInPosition; }
|
||||||
const Attribute& inColor() const { return kInColor; }
|
const Attribute& inColor() const { return kInColor; }
|
||||||
const Attribute& inTextureCoords() const { return kInTextureCoords; }
|
const Attribute& inTextureCoords() const { return fInTextureCoords; }
|
||||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
float getDistanceAdjust() const { return fDistanceAdjust; }
|
float getDistanceAdjust() const { return fDistanceAdjust; }
|
||||||
@ -95,7 +97,8 @@ public:
|
|||||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrDistanceFieldA8TextGeoProc(const sk_sp<GrTextureProxy>* proxies,
|
GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& params,
|
const GrSamplerState& params,
|
||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
@ -104,7 +107,7 @@ private:
|
|||||||
uint32_t flags, const SkMatrix& localMatrix);
|
uint32_t flags, const SkMatrix& localMatrix);
|
||||||
|
|
||||||
const Attribute& onVertexAttribute(int i) const override {
|
const Attribute& onVertexAttribute(int i) const override {
|
||||||
return IthAttribute(i, fInPosition, kInColor, kInTextureCoords);
|
return IthAttribute(i, fInPosition, kInColor, fInTextureCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
||||||
@ -113,6 +116,7 @@ private:
|
|||||||
SkISize fAtlasSize; // size for all textures used with fTextureSamplers[].
|
SkISize fAtlasSize; // size for all textures used with fTextureSamplers[].
|
||||||
SkMatrix fLocalMatrix;
|
SkMatrix fLocalMatrix;
|
||||||
Attribute fInPosition;
|
Attribute fInPosition;
|
||||||
|
Attribute fInTextureCoords;
|
||||||
uint32_t fFlags;
|
uint32_t fFlags;
|
||||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||||
float fDistanceAdjust;
|
float fDistanceAdjust;
|
||||||
@ -120,8 +124,6 @@ private:
|
|||||||
|
|
||||||
static constexpr Attribute kInColor =
|
static constexpr Attribute kInColor =
|
||||||
{"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
{"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
||||||
static constexpr Attribute kInTextureCoords =
|
|
||||||
{"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
|
|
||||||
|
|
||||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
||||||
|
|
||||||
@ -139,12 +141,13 @@ public:
|
|||||||
static constexpr int kMaxTextures = 4;
|
static constexpr int kMaxTextures = 4;
|
||||||
|
|
||||||
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
||||||
static sk_sp<GrGeometryProcessor> Make(const SkMatrix& matrix,
|
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||||
|
const SkMatrix& matrix,
|
||||||
const sk_sp<GrTextureProxy>* proxies,
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& params, uint32_t flags) {
|
const GrSamplerState& params, uint32_t flags) {
|
||||||
return sk_sp<GrGeometryProcessor>(
|
return sk_sp<GrGeometryProcessor>(
|
||||||
new GrDistanceFieldPathGeoProc(matrix, proxies, numActiveProxies, params, flags));
|
new GrDistanceFieldPathGeoProc(caps, matrix, proxies, numActiveProxies, params, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
~GrDistanceFieldPathGeoProc() override {}
|
~GrDistanceFieldPathGeoProc() override {}
|
||||||
@ -153,7 +156,7 @@ public:
|
|||||||
|
|
||||||
const Attribute& inPosition() const { return kInPosition; }
|
const Attribute& inPosition() const { return kInPosition; }
|
||||||
const Attribute& inColor() const { return kInColor; }
|
const Attribute& inColor() const { return kInColor; }
|
||||||
const Attribute& inTextureCoords() const { return kInTextureCoords; }
|
const Attribute& inTextureCoords() const { return fInTextureCoords; }
|
||||||
const SkMatrix& matrix() const { return fMatrix; }
|
const SkMatrix& matrix() const { return fMatrix; }
|
||||||
uint32_t getFlags() const { return fFlags; }
|
uint32_t getFlags() const { return fFlags; }
|
||||||
const SkISize& atlasSize() const { return fAtlasSize; }
|
const SkISize& atlasSize() const { return fAtlasSize; }
|
||||||
@ -165,7 +168,8 @@ public:
|
|||||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrDistanceFieldPathGeoProc(const SkMatrix& matrix,
|
GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
|
||||||
|
const SkMatrix& matrix,
|
||||||
const sk_sp<GrTextureProxy>* proxies,
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState&, uint32_t flags);
|
const GrSamplerState&, uint32_t flags);
|
||||||
@ -176,13 +180,12 @@ private:
|
|||||||
SkMatrix fMatrix; // view matrix if perspective, local matrix otherwise
|
SkMatrix fMatrix; // view matrix if perspective, local matrix otherwise
|
||||||
TextureSampler fTextureSamplers[kMaxTextures];
|
TextureSampler fTextureSamplers[kMaxTextures];
|
||||||
SkISize fAtlasSize; // size for all textures used with fTextureSamplers[].
|
SkISize fAtlasSize; // size for all textures used with fTextureSamplers[].
|
||||||
|
Attribute fInTextureCoords;
|
||||||
uint32_t fFlags;
|
uint32_t fFlags;
|
||||||
static constexpr Attribute kInPosition =
|
static constexpr Attribute kInPosition =
|
||||||
{"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
{"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||||
static constexpr Attribute kInColor =
|
static constexpr Attribute kInColor =
|
||||||
{"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
{"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
||||||
static constexpr Attribute kInTextureCoords =
|
|
||||||
{"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
|
|
||||||
|
|
||||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
||||||
|
|
||||||
@ -214,15 +217,16 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static sk_sp<GrGeometryProcessor> Make(const sk_sp<GrTextureProxy>* proxies,
|
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
int numActiveProxies,
|
int numActiveProxies,
|
||||||
const GrSamplerState& params,
|
const GrSamplerState& params,
|
||||||
DistanceAdjust distanceAdjust,
|
DistanceAdjust distanceAdjust,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||||
return sk_sp<GrGeometryProcessor>(
|
return sk_sp<GrGeometryProcessor>(
|
||||||
new GrDistanceFieldLCDTextGeoProc(proxies, numActiveProxies, params, distanceAdjust,
|
new GrDistanceFieldLCDTextGeoProc(caps, proxies, numActiveProxies, params,
|
||||||
flags, localMatrixIfUsesLocalCoords));
|
distanceAdjust, flags, localMatrixIfUsesLocalCoords));
|
||||||
}
|
}
|
||||||
|
|
||||||
~GrDistanceFieldLCDTextGeoProc() override {}
|
~GrDistanceFieldLCDTextGeoProc() override {}
|
||||||
@ -231,7 +235,7 @@ public:
|
|||||||
|
|
||||||
const Attribute& inPosition() const { return fInPosition; }
|
const Attribute& inPosition() const { return fInPosition; }
|
||||||
const Attribute& inColor() const { return kInColor; }
|
const Attribute& inColor() const { return kInColor; }
|
||||||
const Attribute& inTextureCoords() const { return kInTextureCoords; }
|
const Attribute& inTextureCoords() const { return fInTextureCoords; }
|
||||||
DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; }
|
DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; }
|
||||||
uint32_t getFlags() const { return fFlags; }
|
uint32_t getFlags() const { return fFlags; }
|
||||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||||
@ -244,9 +248,9 @@ public:
|
|||||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrDistanceFieldLCDTextGeoProc(const sk_sp<GrTextureProxy>* proxies, int numActiveProxies,
|
GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps, const sk_sp<GrTextureProxy>* proxies,
|
||||||
const GrSamplerState& params, DistanceAdjust wa, uint32_t flags,
|
int numActiveProxies, const GrSamplerState& params,
|
||||||
const SkMatrix& localMatrix);
|
DistanceAdjust wa, uint32_t flags, const SkMatrix& localMatrix);
|
||||||
|
|
||||||
const Attribute& onVertexAttribute(int) const override;
|
const Attribute& onVertexAttribute(int) const override;
|
||||||
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
|
||||||
@ -256,12 +260,11 @@ private:
|
|||||||
const SkMatrix fLocalMatrix;
|
const SkMatrix fLocalMatrix;
|
||||||
DistanceAdjust fDistanceAdjust;
|
DistanceAdjust fDistanceAdjust;
|
||||||
Attribute fInPosition;
|
Attribute fInPosition;
|
||||||
|
Attribute fInTextureCoords;
|
||||||
uint32_t fFlags;
|
uint32_t fFlags;
|
||||||
|
|
||||||
static constexpr Attribute kInColor =
|
static constexpr Attribute kInColor =
|
||||||
{"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
{"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
||||||
static constexpr Attribute kInTextureCoords =
|
|
||||||
{"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
|
|
||||||
|
|
||||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
||||||
|
|
||||||
|
@ -1828,8 +1828,8 @@ void GrGLGpu::setupGeometry(const GrBuffer* indexBuffer,
|
|||||||
for (int i = 0; i < fHWProgram->numVertexAttributes(); ++i) {
|
for (int i = 0; i < fHWProgram->numVertexAttributes(); ++i) {
|
||||||
const auto& attrib = fHWProgram->vertexAttribute(i);
|
const auto& attrib = fHWProgram->vertexAttribute(i);
|
||||||
static constexpr int kDivisor = 0;
|
static constexpr int kDivisor = 0;
|
||||||
attribState->set(this, attrib.fLocation, vertexBuffer, attrib.fType, vertexStride,
|
attribState->set(this, attrib.fLocation, vertexBuffer, attrib.fCPUType, attrib.fGPUType,
|
||||||
bufferOffset + attrib.fOffset, kDivisor);
|
vertexStride, bufferOffset + attrib.fOffset, kDivisor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (int instanceStride = fHWProgram->instanceStride()) {
|
if (int instanceStride = fHWProgram->instanceStride()) {
|
||||||
@ -1839,8 +1839,9 @@ void GrGLGpu::setupGeometry(const GrBuffer* indexBuffer,
|
|||||||
for (int i = 0; i < fHWProgram->numInstanceAttributes(); ++i, ++attribIdx) {
|
for (int i = 0; i < fHWProgram->numInstanceAttributes(); ++i, ++attribIdx) {
|
||||||
const auto& attrib = fHWProgram->instanceAttribute(i);
|
const auto& attrib = fHWProgram->instanceAttribute(i);
|
||||||
static constexpr int kDivisor = 1;
|
static constexpr int kDivisor = 1;
|
||||||
attribState->set(this, attrib.fLocation, instanceBuffer, attrib.fType, instanceStride,
|
attribState->set(this, attrib.fLocation, instanceBuffer, attrib.fCPUType,
|
||||||
bufferOffset + attrib.fOffset, kDivisor);
|
attrib.fGPUType, instanceStride, bufferOffset + attrib.fOffset,
|
||||||
|
kDivisor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3462,7 +3463,7 @@ void GrGLGpu::clearStencilClipAsDraw(const GrFixedClip& clip, bool insideStencil
|
|||||||
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
||||||
attribs->enableVertexArrays(this, 1);
|
attribs->enableVertexArrays(this, 1);
|
||||||
attribs->set(this, 0, fStencilClipClearArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
attribs->set(this, 0, fStencilClipClearArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
||||||
2 * sizeof(GrGLfloat), 0);
|
kFloat2_GrSLType, 2 * sizeof(GrGLfloat), 0);
|
||||||
|
|
||||||
GrXferProcessor::BlendInfo blendInfo;
|
GrXferProcessor::BlendInfo blendInfo;
|
||||||
blendInfo.reset();
|
blendInfo.reset();
|
||||||
@ -3574,7 +3575,7 @@ void GrGLGpu::clearColorAsDraw(const GrFixedClip& clip, GrGLfloat r, GrGLfloat g
|
|||||||
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
||||||
attribs->enableVertexArrays(this, 1);
|
attribs->enableVertexArrays(this, 1);
|
||||||
attribs->set(this, 0, fClearProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
attribs->set(this, 0, fClearProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
||||||
2 * sizeof(GrGLfloat), 0);
|
kFloat2_GrSLType, 2 * sizeof(GrGLfloat), 0);
|
||||||
|
|
||||||
GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(dst);
|
GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(dst);
|
||||||
this->flushScissor(clip.scissorState(), glrt->getViewport(), origin);
|
this->flushScissor(clip.scissorState(), glrt->getViewport(), origin);
|
||||||
@ -3634,7 +3635,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin,
|
|||||||
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
||||||
attribs->enableVertexArrays(this, 1);
|
attribs->enableVertexArrays(this, 1);
|
||||||
attribs->set(this, 0, fCopyProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
attribs->set(this, 0, fCopyProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
||||||
2 * sizeof(GrGLfloat), 0);
|
kFloat2_GrSLType, 2 * sizeof(GrGLfloat), 0);
|
||||||
|
|
||||||
// dst rect edges in NDC (-1 to 1)
|
// dst rect edges in NDC (-1 to 1)
|
||||||
int dw = dst->width();
|
int dw = dst->width();
|
||||||
@ -3833,7 +3834,7 @@ bool GrGLGpu::onRegenerateMipMapLevels(GrTexture* texture) {
|
|||||||
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
|
||||||
attribs->enableVertexArrays(this, 1);
|
attribs->enableVertexArrays(this, 1);
|
||||||
attribs->set(this, 0, fMipmapProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
attribs->set(this, 0, fMipmapProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
|
||||||
2 * sizeof(GrGLfloat), 0);
|
kFloat2_GrSLType, 2 * sizeof(GrGLfloat), 0);
|
||||||
|
|
||||||
// Set "simple" state once:
|
// Set "simple" state once:
|
||||||
GrXferProcessor::BlendInfo blendInfo;
|
GrXferProcessor::BlendInfo blendInfo;
|
||||||
|
@ -33,7 +33,8 @@ public:
|
|||||||
* Additionally, these store the attribute location.
|
* Additionally, these store the attribute location.
|
||||||
*/
|
*/
|
||||||
struct Attribute {
|
struct Attribute {
|
||||||
GrVertexAttribType fType;
|
GrVertexAttribType fCPUType;
|
||||||
|
GrSLType fGPUType;
|
||||||
size_t fOffset;
|
size_t fOffset;
|
||||||
GrGLint fLocation;
|
GrGLint fLocation;
|
||||||
};
|
};
|
||||||
|
@ -76,70 +76,11 @@ static AttribLayout attrib_layout(GrVertexAttribType type) {
|
|||||||
return {false, 0, 0};
|
return {false, 0, 0};
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool GrVertexAttribTypeIsIntType(const GrShaderCaps* shaderCaps,
|
|
||||||
GrVertexAttribType type) {
|
|
||||||
switch (type) {
|
|
||||||
case kFloat_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kFloat2_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kFloat3_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kFloat4_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kHalf_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kHalf2_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kHalf3_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kHalf4_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kInt2_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kInt3_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kInt4_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kByte_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kByte2_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kByte3_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kByte4_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUByte_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUByte2_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUByte3_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUByte4_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUByte_norm_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kUByte4_norm_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kShort2_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUShort2_GrVertexAttribType:
|
|
||||||
return shaderCaps->integerSupport(); // FIXME: caller should handle this.
|
|
||||||
case kUShort2_norm_GrVertexAttribType:
|
|
||||||
return false;
|
|
||||||
case kInt_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
case kUint_GrVertexAttribType:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SK_ABORT("Unexpected attribute type");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrGLAttribArrayState::set(GrGLGpu* gpu,
|
void GrGLAttribArrayState::set(GrGLGpu* gpu,
|
||||||
int index,
|
int index,
|
||||||
const GrBuffer* vertexBuffer,
|
const GrBuffer* vertexBuffer,
|
||||||
GrVertexAttribType type,
|
GrVertexAttribType cpuType,
|
||||||
|
GrSLType gpuType,
|
||||||
GrGLsizei stride,
|
GrGLsizei stride,
|
||||||
size_t offsetInBytes,
|
size_t offsetInBytes,
|
||||||
int divisor) {
|
int divisor) {
|
||||||
@ -147,13 +88,14 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
|
|||||||
SkASSERT(0 == divisor || gpu->caps()->instanceAttribSupport());
|
SkASSERT(0 == divisor || gpu->caps()->instanceAttribSupport());
|
||||||
AttribArrayState* array = &fAttribArrayStates[index];
|
AttribArrayState* array = &fAttribArrayStates[index];
|
||||||
if (array->fVertexBufferUniqueID != vertexBuffer->uniqueID() ||
|
if (array->fVertexBufferUniqueID != vertexBuffer->uniqueID() ||
|
||||||
array->fType != type ||
|
array->fCPUType != cpuType ||
|
||||||
|
array->fGPUType != gpuType ||
|
||||||
array->fStride != stride ||
|
array->fStride != stride ||
|
||||||
array->fOffset != offsetInBytes) {
|
array->fOffset != offsetInBytes) {
|
||||||
gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
|
gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
|
||||||
const AttribLayout& layout = attrib_layout(type);
|
const AttribLayout& layout = attrib_layout(cpuType);
|
||||||
const GrGLvoid* offsetAsPtr = reinterpret_cast<const GrGLvoid*>(offsetInBytes);
|
const GrGLvoid* offsetAsPtr = reinterpret_cast<const GrGLvoid*>(offsetInBytes);
|
||||||
if (!GrVertexAttribTypeIsIntType(gpu->caps()->shaderCaps(), type)) {
|
if (GrSLTypeIsFloatType(gpuType)) {
|
||||||
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
|
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
|
||||||
layout.fCount,
|
layout.fCount,
|
||||||
layout.fType,
|
layout.fType,
|
||||||
@ -170,7 +112,8 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
|
|||||||
offsetAsPtr));
|
offsetAsPtr));
|
||||||
}
|
}
|
||||||
array->fVertexBufferUniqueID = vertexBuffer->uniqueID();
|
array->fVertexBufferUniqueID = vertexBuffer->uniqueID();
|
||||||
array->fType = type;
|
array->fCPUType = cpuType;
|
||||||
|
array->fGPUType = gpuType;
|
||||||
array->fStride = stride;
|
array->fStride = stride;
|
||||||
array->fOffset = offsetInBytes;
|
array->fOffset = offsetInBytes;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ public:
|
|||||||
void set(GrGLGpu*,
|
void set(GrGLGpu*,
|
||||||
int attribIndex,
|
int attribIndex,
|
||||||
const GrBuffer* vertexBuffer,
|
const GrBuffer* vertexBuffer,
|
||||||
GrVertexAttribType type,
|
GrVertexAttribType cpuType,
|
||||||
|
GrSLType gpuType,
|
||||||
GrGLsizei stride,
|
GrGLsizei stride,
|
||||||
size_t offsetInBytes,
|
size_t offsetInBytes,
|
||||||
int divisor = 0);
|
int divisor = 0);
|
||||||
@ -77,7 +78,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrGpuResource::UniqueID fVertexBufferUniqueID;
|
GrGpuResource::UniqueID fVertexBufferUniqueID;
|
||||||
GrVertexAttribType fType;
|
GrVertexAttribType fCPUType;
|
||||||
|
GrSLType fGPUType;
|
||||||
GrGLsizei fStride;
|
GrGLsizei fStride;
|
||||||
size_t fOffset;
|
size_t fOffset;
|
||||||
int fDivisor;
|
int fDivisor;
|
||||||
|
@ -136,7 +136,8 @@ void GrGLProgramBuilder::computeCountsAndStrides(GrGLuint programID,
|
|||||||
fAttributes.reset(
|
fAttributes.reset(
|
||||||
new GrGLProgram::Attribute[fVertexAttributeCnt + fInstanceAttributeCnt]);
|
new GrGLProgram::Attribute[fVertexAttributeCnt + fInstanceAttributeCnt]);
|
||||||
auto addAttr = [&](int i, const auto& a, size_t* stride) {
|
auto addAttr = [&](int i, const auto& a, size_t* stride) {
|
||||||
fAttributes[i].fType = a.cpuType();
|
fAttributes[i].fCPUType = a.cpuType();
|
||||||
|
fAttributes[i].fGPUType = a.gpuType();
|
||||||
fAttributes[i].fOffset = *stride;
|
fAttributes[i].fOffset = *stride;
|
||||||
*stride += a.sizeAlign4();
|
*stride += a.sizeAlign4();
|
||||||
fAttributes[i].fLocation = i;
|
fAttributes[i].fLocation = i;
|
||||||
|
@ -71,14 +71,7 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
|
|||||||
case kUShort_GrSLType:
|
case kUShort_GrSLType:
|
||||||
return "ushort";
|
return "ushort";
|
||||||
case kUShort2_GrSLType:
|
case kUShort2_GrSLType:
|
||||||
if (shaderCaps->integerSupport()) {
|
return "ushort2";
|
||||||
return "ushort2";
|
|
||||||
} else {
|
|
||||||
// uint2 (aka uvec2) isn't supported in GLSL ES 1.00/GLSL 1.20
|
|
||||||
// FIXME: this should be handled by the client code rather than relying on
|
|
||||||
// unconventional ushort2 behavior.
|
|
||||||
return "float2";
|
|
||||||
}
|
|
||||||
case kUShort3_GrSLType:
|
case kUShort3_GrSLType:
|
||||||
return "ushort3";
|
return "ushort3";
|
||||||
case kUShort4_GrSLType:
|
case kUShort4_GrSLType:
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "GrAtlasTextOp.h"
|
#include "GrAtlasTextOp.h"
|
||||||
|
|
||||||
|
#include "GrCaps.h"
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
#include "GrContextPriv.h"
|
||||||
#include "GrMemoryPool.h"
|
#include "GrMemoryPool.h"
|
||||||
@ -312,13 +313,14 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
|
|||||||
|
|
||||||
bool vmPerspective = fGeoData[0].fViewMatrix.hasPerspective();
|
bool vmPerspective = fGeoData[0].fViewMatrix.hasPerspective();
|
||||||
if (this->usesDistanceFields()) {
|
if (this->usesDistanceFields()) {
|
||||||
flushInfo.fGeometryProcessor = this->setupDfProcessor(proxies, numActiveProxies);
|
flushInfo.fGeometryProcessor = this->setupDfProcessor(*target->caps().shaderCaps(),
|
||||||
|
proxies, numActiveProxies);
|
||||||
} else {
|
} else {
|
||||||
GrSamplerState samplerState = fNeedsGlyphTransform ? GrSamplerState::ClampBilerp()
|
GrSamplerState samplerState = fNeedsGlyphTransform ? GrSamplerState::ClampBilerp()
|
||||||
: GrSamplerState::ClampNearest();
|
: GrSamplerState::ClampNearest();
|
||||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
||||||
this->color(), proxies, numActiveProxies, samplerState, maskFormat,
|
*target->caps().shaderCaps(), this->color(), proxies, numActiveProxies, samplerState,
|
||||||
localMatrix, vmPerspective);
|
maskFormat, localMatrix, vmPerspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
flushInfo.fGlyphsToFlush = 0;
|
flushInfo.fGlyphsToFlush = 0;
|
||||||
@ -521,7 +523,8 @@ GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& ca
|
|||||||
|
|
||||||
// TODO trying to figure out why lcd is so whack
|
// TODO trying to figure out why lcd is so whack
|
||||||
// (see comments in GrTextContext::ComputeCanonicalColor)
|
// (see comments in GrTextContext::ComputeCanonicalColor)
|
||||||
sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const sk_sp<GrTextureProxy>* proxies,
|
sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
unsigned int numActiveProxies) const {
|
unsigned int numActiveProxies) const {
|
||||||
bool isLCD = this->isLCD();
|
bool isLCD = this->isLCD();
|
||||||
|
|
||||||
@ -546,7 +549,7 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const sk_sp<GrTexture
|
|||||||
GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
|
GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
|
||||||
GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
|
GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
|
||||||
redCorrection, greenCorrection, blueCorrection);
|
redCorrection, greenCorrection, blueCorrection);
|
||||||
return GrDistanceFieldLCDTextGeoProc::Make(proxies, numActiveProxies,
|
return GrDistanceFieldLCDTextGeoProc::Make(caps, proxies, numActiveProxies,
|
||||||
GrSamplerState::ClampBilerp(), widthAdjust,
|
GrSamplerState::ClampBilerp(), widthAdjust,
|
||||||
fDFGPFlags, localMatrix);
|
fDFGPFlags, localMatrix);
|
||||||
} else {
|
} else {
|
||||||
@ -558,11 +561,11 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const sk_sp<GrTexture
|
|||||||
correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
|
correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
|
||||||
fUseGammaCorrectDistanceTable);
|
fUseGammaCorrectDistanceTable);
|
||||||
}
|
}
|
||||||
return GrDistanceFieldA8TextGeoProc::Make(proxies, numActiveProxies,
|
return GrDistanceFieldA8TextGeoProc::Make(caps, proxies, numActiveProxies,
|
||||||
GrSamplerState::ClampBilerp(),
|
GrSamplerState::ClampBilerp(),
|
||||||
correction, fDFGPFlags, localMatrix);
|
correction, fDFGPFlags, localMatrix);
|
||||||
#else
|
#else
|
||||||
return GrDistanceFieldA8TextGeoProc::Make(proxies, numActiveProxies,
|
return GrDistanceFieldA8TextGeoProc::Make(caps, proxies, numActiveProxies,
|
||||||
GrSamplerState::ClampBilerp(),
|
GrSamplerState::ClampBilerp(),
|
||||||
fDFGPFlags, localMatrix);
|
fDFGPFlags, localMatrix);
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,7 +151,8 @@ private:
|
|||||||
|
|
||||||
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
|
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
|
||||||
|
|
||||||
sk_sp<GrGeometryProcessor> setupDfProcessor(const sk_sp<GrTextureProxy>* proxies,
|
sk_sp<GrGeometryProcessor> setupDfProcessor(const GrShaderCaps& caps,
|
||||||
|
const sk_sp<GrTextureProxy>* proxies,
|
||||||
unsigned int numActiveProxies) const;
|
unsigned int numActiveProxies) const;
|
||||||
|
|
||||||
SkAutoSTMalloc<kMinGeometryAllocated, Geometry> fGeoData;
|
SkAutoSTMalloc<kMinGeometryAllocated, Geometry> fGeoData;
|
||||||
|
@ -348,8 +348,8 @@ private:
|
|||||||
matrix = &SkMatrix::I();
|
matrix = &SkMatrix::I();
|
||||||
}
|
}
|
||||||
flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(
|
flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(
|
||||||
*matrix, fAtlas->getProxies(), fAtlas->numActivePages(),
|
*target->caps().shaderCaps(), *matrix, fAtlas->getProxies(),
|
||||||
GrSamplerState::ClampBilerp(), flags);
|
fAtlas->numActivePages(), GrSamplerState::ClampBilerp(), flags);
|
||||||
} else {
|
} else {
|
||||||
SkMatrix invert;
|
SkMatrix invert;
|
||||||
if (fHelper.usesLocalCoords()) {
|
if (fHelper.usesLocalCoords()) {
|
||||||
@ -359,9 +359,9 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
||||||
this->color(), fAtlas->getProxies(), fAtlas->numActivePages(),
|
*target->caps().shaderCaps(), this->color(), fAtlas->getProxies(),
|
||||||
GrSamplerState::ClampNearest(), kA8_GrMaskFormat, invert,
|
fAtlas->numActivePages(), GrSamplerState::ClampNearest(), kA8_GrMaskFormat,
|
||||||
false);
|
invert, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate vertices
|
// allocate vertices
|
||||||
|
Loading…
Reference in New Issue
Block a user