bool isWrapped,
GrTexture* texture,
const GrTextureDesc& desc,
- Origin origin)
+ GrSurfaceOrigin origin)
: INHERITED(gpu, isWrapped, desc, origin)
, fStencilBuffer(NULL)
, fTexture(texture) {
*/
int height() const { return fDesc.fHeight; }
- /**
- * Some surfaces will be stored such that the upper and left edges of the content meet at the
- * the origin (in texture coord space) and for other surfaces the lower and left edges meet at
- * the origin. Render-targets are always consistent with the convention of the underlying
- * backend API to make it easier to mix native backend rendering with Skia rendering. Wrapped
- * backend surfaces always use the backend's convention as well.
- */
- enum Origin {
- kTopLeft_Origin,
- kBottomLeft_Origin,
- };
- Origin origin() const {
- GrAssert(kTopLeft_Origin == fOrigin || kBottomLeft_Origin == fOrigin);
+ GrSurfaceOrigin origin() const {
+ GrAssert(kTopLeft_SurfaceOrigin == fOrigin || kBottomLeft_SurfaceOrigin == fOrigin);
return fOrigin;
}
uint32_t pixelOpsFlags = 0) = 0;
protected:
- GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, Origin origin)
+ GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, GrSurfaceOrigin origin)
: INHERITED(gpu, isWrapped)
, fDesc(desc)
, fOrigin(origin) {
GrTextureDesc fDesc;
private:
- Origin fOrigin;
+ GrSurfaceOrigin fOrigin;
typedef GrResource INHERITED;
};
// base class cons sets to NULL
// subclass cons can create and set
- GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, Origin origin)
+ GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, GrSurfaceOrigin origin)
: INHERITED(gpu, isWrapped, desc, origin)
, fRenderTarget(NULL) {
kGrColorTableSize = 256 * 4 //sizeof(GrColor)
};
+/**
+ * Some textures will be stored such that the upper and left edges of the content meet at the
+ * the origin (in texture coord space) and for other textures the lower and left edges meet at
+ * the origin. Render-targets are always consistent with the convention of the underlying
+ * backend API to make it easier to mix native backend rendering with Skia rendering.
+ */
+
+enum GrSurfaceOrigin {
+ kBottomLeft_GrSurfaceOrigin,
+ kTopLeft_GrSurfaceOrigin,
+};
/**
* Describes a texture to be created.
struct GrBackendTextureDesc {
GrBackendTextureDesc() { memset(this, 0, sizeof(*this)); }
GrBackendTextureFlags fFlags;
+ GrSurfaceOrigin fOrigin;
int fWidth; //<! width in pixels
int fHeight; //<! height in pixels
GrPixelConfig fConfig; //<! color format
colorTex);
uman.set2f(fScaleUni, SkScalarToFloat(displacementMap.scale()),
- colorTex->origin() == GrSurface::kTopLeft_Origin ?
+ colorTex->origin() == kTopLeft_GrSurfaceOrigin ?
SkScalarToFloat(displacementMap.scale()) :
SkScalarToFloat(-displacementMap.scale()));
}
void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
const GrLightingEffect& effect = GetEffectFromStage<GrLightingEffect>(stage);
GrTexture* texture = effect.texture(0);
- float ySign = texture->origin() == GrSurface::kTopLeft_Origin ? -1.0f : 1.0f;
+ float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
uman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
uman.set1f(fSurfaceScaleUni, effect.surfaceScale());
fLight->setData(uman, effect.light());
GrAssert(effect.kernelSize() == fKernelSize);
GrAssert(effect.tileMode() == fTileMode);
float imageIncrement[2];
- float ySign = texture.origin() == GrSurface::kTopLeft_Origin ? 1.0f : -1.0f;
+ float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / texture.width();
imageIncrement[1] = ySign / texture.height();
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
SkScalarToFloat(domain.bottom())
};
// vertical flip if necessary
- if (GrSurface::kBottomLeft_Origin == effect.texture(0)->origin()) {
+ if (kBottomLeft_GrSurfaceOrigin == effect.texture(0)->origin()) {
values[1] = 1.0f - values[1];
values[3] = 1.0f - values[3];
// The top and bottom were just flipped, so correct the ordering
SkMatrix::kPerspective_Mask;
int combinedTypes = type0 | type1;
- bool reverseY = (NULL != texture) && GrSurface::kBottomLeft_Origin == texture->origin();
+ bool reverseY = (NULL != texture) && kBottomLeft_GrSurfaceOrigin == texture->origin();
if (SkMatrix::kPerspective_Mask & combinedTypes) {
return kGeneral_Key;
case kVoid_GrSLType:
GrAssert(matrix.isIdentity());
GrAssert(coordChangeMatrix.isIdentity());
- GrAssert(NULL == texture || GrSurface::kTopLeft_Origin == texture->origin());
+ GrAssert(NULL == texture || kTopLeft_GrSurfaceOrigin == texture->origin());
return;
case kVec2f_GrSLType: {
GrAssert(SkMatrix::kTranslate_Mask == (matrix.getType() | coordChangeMatrix.getType()));
- GrAssert(NULL == texture || GrSurface::kTopLeft_Origin == texture->origin());
+ GrAssert(NULL == texture || kTopLeft_GrSurfaceOrigin == texture->origin());
SkScalar tx = matrix[SkMatrix::kMTransX] + coordChangeMatrix[SkMatrix::kMTransX];
SkScalar ty = matrix[SkMatrix::kMTransY] + coordChangeMatrix[SkMatrix::kMTransY];
if (fPrevMatrix.get(SkMatrix::kMTransX) != tx ||
case kMat33f_GrSLType: {
SkMatrix combined;
combined.setConcat(matrix, coordChangeMatrix);
- if (NULL != texture && GrSurface::kBottomLeft_Origin == texture->origin()) {
+ if (NULL != texture && kBottomLeft_GrSurfaceOrigin == texture->origin()) {
// combined.postScale(1,-1);
// combined.postTranslate(0,1);
combined.set(SkMatrix::kMSkewY,
viewport.fWidth, viewport.fHeight,
desc.fConfig, desc.fSampleCnt),
texture->origin()) {
- GrAssert(kBottomLeft_Origin == texture->origin());
+ GrAssert(kBottomLeft_GrSurfaceOrigin == texture->origin());
GrAssert(NULL != texID);
GrAssert(NULL != texture);
// FBO 0 can't also be a texture, right?
MakeDesc(kNone_GrTextureFlags,
viewport.fWidth, viewport.fHeight,
desc.fConfig, desc.fSampleCnt),
- kBottomLeft_Origin) {
+ kBottomLeft_GrSurfaceOrigin) {
this->init(desc, viewport, NULL);
}
textureDesc.fIsWrapped));
if (NULL != rtDesc) {
- GrAssert(kBottomLeft_Origin == textureDesc.fOrigin);
+ GrAssert(kBottomLeft_GrSurfaceOrigin == textureDesc.fSurfaceOrigin);
GrGLIRect vp;
vp.fLeft = 0;
vp.fWidth = textureDesc.fWidth;
struct Desc : public GrTextureDesc {
GrGLuint fTextureID;
bool fIsWrapped;
- Origin fOrigin;
+ GrSurfaceOrigin fOrigin;
};
// creates a texture that is also an RT
return NULL;
}
+ // FIXME: add support for TopLeft RT's by flipping all draws.
+ if (desc.fFlags & kRenderTarget_GrBackendTextureFlag &&
+ kBottomLeft_GrSurfaceOrigin != desc.fOrigin) {
+ return NULL;
+ }
+
int maxSize = this->getCaps().maxTextureSize();
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
return NULL;
glTexDesc.fSampleCnt = desc.fSampleCnt;
glTexDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle);
glTexDesc.fIsWrapped = true;
- glTexDesc.fOrigin = GrSurface::kBottomLeft_Origin;
+ glTexDesc.fOrigin = desc.fOrigin;
GrGLTexture* texture = NULL;
if (desc.fFlags & kRenderTarget_GrBackendTextureFlag) {
bool swFlipY = false;
bool glFlipY = false;
if (NULL != data) {
- if (GrSurface::kBottomLeft_Origin == desc.fOrigin) {
+ if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
if (this->glCaps().unpackFlipYSupport()) {
glFlipY = true;
} else {
// We keep GrRenderTargets in GL's normal orientation so that they
// can be drawn to by the outside world without the client having
// to render upside down.
- glTexDesc.fOrigin = renderTarget ? GrSurface::kBottomLeft_Origin : GrSurface::kTopLeft_Origin;
+ glTexDesc.fOrigin = renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
glRTDesc.fSampleCnt = desc.fSampleCnt;
if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() &&