aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rwxr-xr-xsrc/gpu/GrContext.cpp11
-rw-r--r--src/gpu/SkGpuDevice.cpp38
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp6
-rw-r--r--src/gpu/gl/GrGLProgram.cpp3
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp7
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp6
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h6
-rw-r--r--src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp35
8 files changed, 70 insertions, 42 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index cb68374c72..cc6a637267 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -795,10 +795,11 @@ void GrContext::drawRect(const GrPaint& paint,
}
}
-void GrContext::drawRectToRect(const GrPaint& paint,
- const SkMatrix& viewMatrix,
- const SkRect& dstRect,
- const SkRect& localRect) {
+void GrContext::drawNonAARectToRect(const GrPaint& paint,
+ const SkMatrix& viewMatrix,
+ const SkRect& rectToDraw,
+ const SkRect& localRect,
+ const SkMatrix* localMatrix) {
AutoCheckFlush acf(this);
GrDrawState drawState;
GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf);
@@ -808,7 +809,7 @@ void GrContext::drawRectToRect(const GrPaint& paint,
GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target);
- target->drawRect(&drawState, paint.getColor(), dstRect, &localRect, NULL);
+ target->drawRect(&drawState, paint.getColor(), rectToDraw, &localRect, localMatrix);
}
static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 040cea8356..5f4713245e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -574,16 +574,18 @@ namespace {
// Return true if the mask was successfully drawn.
bool draw_mask(GrContext* context, const SkMatrix& viewMatrix, const SkRect& maskRect,
GrPaint* grp, GrTexture* mask) {
- if (!grp->localCoordChangeInverse(viewMatrix)) {
- return false;
- }
-
SkMatrix matrix;
matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
matrix.postIDiv(mask->width(), mask->height());
- grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix))->unref();
- context->drawRect(*grp, SkMatrix::I(), maskRect);
+ grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix,
+ kDevice_GrCoordSet))->unref();
+
+ SkMatrix inverse;
+ if (!viewMatrix.invert(&inverse)) {
+ return false;
+ }
+ context->drawNonAARectWithLocalMatrix(*grp, SkMatrix::I(), maskRect, inverse);
return true;
}
@@ -1381,7 +1383,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
SkColor2GrColor(paint.getColor());
SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint);
- fContext->drawRectToRect(grPaint, viewMatrix, dstRect, paintRect);
+ fContext->drawNonAARectToRect(grPaint, viewMatrix, dstRect, paintRect);
}
bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
@@ -1452,16 +1454,16 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()),
false, &grPaint);
- fContext->drawRectToRect(grPaint,
- SkMatrix::I(),
- SkRect::MakeXYWH(SkIntToScalar(left),
- SkIntToScalar(top),
- SkIntToScalar(w),
- SkIntToScalar(h)),
- SkRect::MakeXYWH(0,
- 0,
- SK_Scalar1 * w / texture->width(),
- SK_Scalar1 * h / texture->height()));
+ fContext->drawNonAARectToRect(grPaint,
+ SkMatrix::I(),
+ SkRect::MakeXYWH(SkIntToScalar(left),
+ SkIntToScalar(top),
+ SkIntToScalar(w),
+ SkIntToScalar(h)),
+ SkRect::MakeXYWH(0,
+ 0,
+ SK_Scalar1 * w / texture->width(),
+ SK_Scalar1 * h / texture->height()));
}
void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap,
@@ -1574,7 +1576,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(),
SK_Scalar1 * h / devTex->height());
- fContext->drawRectToRect(grPaint, SkMatrix::I(), dstRect, srcRect);
+ fContext->drawNonAARectToRect(grPaint, SkMatrix::I(), dstRect, srcRect);
}
bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 3a658ace26..4412c43736 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -231,19 +231,19 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
context->setRenderTarget(readTex->asRenderTarget());
GrPaint paint1;
paint1.addColorProcessor(pmToUPM1);
- context->drawRectToRect(paint1, SkMatrix::I(), kDstRect, kSrcRect);
+ context->drawNonAARectToRect(paint1, SkMatrix::I(), kDstRect, kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
context->setRenderTarget(tempTex->asRenderTarget());
GrPaint paint2;
paint2.addColorProcessor(upmToPM);
- context->drawRectToRect(paint2, SkMatrix::I(), kDstRect, kSrcRect);
+ context->drawNonAARectToRect(paint2, SkMatrix::I(), kDstRect, kSrcRect);
context->setRenderTarget(readTex->asRenderTarget());
GrPaint paint3;
paint3.addColorProcessor(pmToUPM2);
- context->drawRectToRect(paint3, SkMatrix::I(), kDstRect, kSrcRect);
+ context->drawNonAARectToRect(paint3, SkMatrix::I(), kDstRect, kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 0f4b70de2b..f8770b3664 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -32,7 +32,8 @@ static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, int tr
SkMatrix combined;
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
- // If we have explicit local coords then we shouldn't need a coord change.
+ // If we have explicit local coords or are in device coords then we shouldn't need a coord
+ // change.
const SkMatrix& ccm = stage.getCoordChangeMatrix();
combined.setConcat(coordTransform.getMatrix(), ccm);
} else {
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 06377c758e..6e3128ceaf 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -52,8 +52,9 @@ enum {
kPrecisionShift = kMatrixTypeKeyBits,
kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)),
+ kDeviceCoords_Flag = kPositionCoords_Flag + kPositionCoords_Flag,
- kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 1,
+ kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 2,
};
GR_STATIC_ASSERT(kHigh_GrSLPrecision < (1 << kPrecisionBits));
@@ -78,8 +79,10 @@ static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE
}
const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransform(t);
- if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLocalCoords) {
+ if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLocalCoords) {
key |= kPositionCoords_Flag;
+ } else if (kDevice_GrCoordSet == coordTransform.sourceCoords()) {
+ key |= kDeviceCoords_Flag;
}
GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits));
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 6f3214f23a..861410bf13 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -401,12 +401,10 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
varyingName = suffixedVaryingName.c_str();
}
- bool useLocalCoords = kLocal_GrCoordSet == processor->coordTransform(t).sourceCoords();
- const char* coords = useLocalCoords ? fVS.localCoords() : fVS.positionCoords();
-
+ GrCoordSet coordType = processor->coordTransform(t).sourceCoords();
GrGLVertToFrag v(varyingType);
this->addVarying(varyingName, &v, precision);
- fCoordVaryings.push_back(TransformVarying(v, uniName, coords));
+ fCoordVaryings.push_back(TransformVarying(v, uniName, coordType));
SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 3fdccca393..032fa57fa2 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -352,11 +352,11 @@ protected:
int stageIndex() const { return fStageIndex; }
struct TransformVarying {
- TransformVarying(const GrGLVarying& v, const char* uniName, const char* sourceCoords)
- : fV(v), fUniName(uniName), fSourceCoords(sourceCoords) {}
+ TransformVarying(const GrGLVarying& v, const char* uniName, GrCoordSet coordSet)
+ : fV(v), fUniName(uniName), fCoordSet(coordSet) {}
GrGLVarying fV;
SkString fUniName;
- SkString fSourceCoords;
+ GrCoordSet fCoordSet;
};
const char* rtAdjustment() const { return "rtAdjustment"; }
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
index 1d97e85234..317657e61f 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
@@ -53,16 +53,39 @@ void GrGLVertexBuilder::transformToNormalizedDeviceSpace() {
SkTArray<GrGLProgramBuilder::TransformVarying, true>& transVs = fProgramBuilder->fCoordVaryings;
int transformCount = transVs.count();
for (int i = 0; i < transformCount; i++) {
- const char* coords = transVs[i].fSourceCoords.c_str();
+ GrCoordSet coordSet = transVs[i].fCoordSet;
+ const char* coords;
+ switch (coordSet) {
+ default:
+ SkFAIL("Case missing");
+ case kPosition_GrCoordSet:
+ coords = this->positionCoords();
+ break;
+ case kLocal_GrCoordSet:
+ coords = this->localCoords();
+ break;
+ case kDevice_GrCoordSet:
+ coords = this->glPosition();
+ break;
+ }
// varying = matrix * coords (logically)
const GrGLVarying& v = transVs[i].fV;
- if (kVec2f_GrSLType == v.fType) {
- this->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.fVsOut, transVs[i].fUniName.c_str(),
- coords);
+ if (kDevice_GrCoordSet == coordSet) {
+ if (kVec2f_GrSLType == v.fType) {
+ this->codeAppendf("%s = (%s * %s).xy;", v.fVsOut, transVs[i].fUniName.c_str(),
+ coords);
+ } else {
+ this->codeAppendf("%s = %s * %s;", v.fVsOut, transVs[i].fUniName.c_str(), coords);
+ }
} else {
- this->codeAppendf("%s = %s * vec3(%s, 1);", v.fVsOut, transVs[i].fUniName.c_str(),
- coords);
+ if (kVec2f_GrSLType == v.fType) {
+ this->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.fVsOut, transVs[i].fUniName.c_str(),
+ coords);
+ } else {
+ this->codeAppendf("%s = %s * vec3(%s, 1);", v.fVsOut, transVs[i].fUniName.c_str(),
+ coords);
+ }
}
}