Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: src/gpu/GrContext.cpp

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrContext.cpp
===================================================================
--- src/gpu/GrContext.cpp (revision 8216)
+++ src/gpu/GrContext.cpp (working copy)
@@ -358,11 +358,11 @@
{kVec2f_GrVertexAttribType, 0},
{kVec2f_GrVertexAttribType, sizeof(GrPoint)}
};
- static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(0);
+ static const GrAttribBindings kAttribBindings = GrDrawState::kLocalCoords_AttribBindingsBit;
drawState->setAttribBindings(kAttribBindings);
drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs));
drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0);
- drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, 1);
+ drawState->setAttribIndex(GrDrawState::kLocalCoords_AttribIndex, 1);
GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0);
if (arg.succeeded()) {
@@ -844,21 +844,15 @@
void GrContext::drawRectToRect(const GrPaint& paint,
const GrRect& dstRect,
- const GrRect& srcRect,
+ const GrRect& localRect,
const SkMatrix* dstMatrix,
- const SkMatrix* srcMatrix) {
+ const SkMatrix* localMatrix) {
SK_TRACE_EVENT0("GrContext::drawRectToRect");
- // srcRect refers to paint's first color stage
- if (!paint.isColorStageEnabled(0)) {
- drawRect(paint, dstRect, -1, dstMatrix);
- return;
- }
-
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
+ GrDrawState::AutoStageDisable atr(fDrawState);
#if GR_STATIC_RECT_VB
- GrDrawState::AutoStageDisable atr(fDrawState);
GrDrawState* drawState = target->drawState();
SkMatrix m;
@@ -870,20 +864,22 @@
m.postConcat(*dstMatrix);
}
- // The first color stage's coords come from srcRect rather than applying a matrix to dstRect.
- // We explicitly compute a matrix for that stage below, no need to adjust here.
- static const uint32_t kExplicitCoordMask = 1 << GrPaint::kFirstColorStage;
- GrDrawState::AutoViewMatrixRestore avmr(drawState, m, kExplicitCoordMask);
+ // This code path plays a little fast and loose with the notion of local coords and coord
+ // change matrices in order to account for localRect and localMatrix. The unit square VB only
+ // has one set of coords. Rather than using AutoViewMatrixRestore we instead directly set concat
+ // with m and then call GrDrawState::localCoordChange() with a matrix that accounts for
+ // localRect and localMatrix. This code path is preventing some encapsulation in GrDrawState.
robertphillips 2013/03/19 15:09:38 matrix -> savedMatrix, origMatrix?
bsalomon 2013/03/19 19:34:43 Done. (savedViewMatrix)
+ SkMatrix matrix = drawState->getViewMatrix();
+ drawState->preConcatViewMatrix(m);
- m.setAll(srcRect.width(), 0, srcRect.fLeft,
- 0, srcRect.height(), srcRect.fTop,
- 0, 0, SkMatrix::I()[8]);
- if (NULL != srcMatrix) {
- m.postConcat(*srcMatrix);
+ m.setAll(localRect.width(), 0, localRect.fLeft,
+ 0, localRect.height(), localRect.fTop,
+ 0, 0, SkMatrix::I()[8]);
+ if (NULL != localMatrix) {
+ m.postConcat(*localMatrix);
}
+ drawState->localCoordChange(m);
- drawState->preConcatStageMatrices(kExplicitCoordMask, m);
-
const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer();
if (NULL == sqVB) {
GrPrintf("Failed to create static rect vb.\n");
@@ -892,10 +888,9 @@
drawState->setDefaultVertexAttribs();
target->setVertexSourceToBuffer(sqVB);
target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
+ drawState->setViewMatrix(matrix);
#else
- GrDrawState::AutoStageDisable atr(fDrawState);
-
- target->drawRect(dstRect, dstMatrix, &srcRect, srcMatrix, 0);
+ target->drawRect(dstRect, dstMatrix, &localRect, localMatrix);
#endif
}
@@ -929,8 +924,8 @@
// set up optional texture coordinate attributes
if (NULL != texCoords) {
- bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(0);
- drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count());
+ bindings |= GrDrawState::kLocalCoords_AttribBindingsBit;
+ drawState->setAttribIndex(GrDrawState::kLocalCoords_AttribIndex, attribs.count());
currAttrib.set(kVec2f_GrVertexAttribType, currentOffset);
attribs.push_back(currAttrib);
texOffset = currentOffset;

Powered by Google App Engine
This is Rietveld 408576698