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

Side by Side Diff: src/gpu/GrSWMaskHelper.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrSWMaskHelper.h" 8 #include "GrSWMaskHelper.h"
9 #include "GrDrawState.h" 9 #include "GrDrawState.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 GrDrawState::AutoDeviceCoordDraw adcd(drawState); 190 GrDrawState::AutoDeviceCoordDraw adcd(drawState);
191 if (!adcd.succeeded()) { 191 if (!adcd.succeeded()) {
192 return; 192 return;
193 } 193 }
194 enum { 194 enum {
195 // the SW path renderer shares this stage with glyph 195 // the SW path renderer shares this stage with glyph
196 // rendering (kGlyphMaskStage in GrTextContext) 196 // rendering (kGlyphMaskStage in GrTextContext)
197 // && edge rendering (kEdgeEffectStage in GrContext) 197 // && edge rendering (kEdgeEffectStage in GrContext)
198 kPathMaskStage = GrPaint::kTotalStages, 198 kPathMaskStage = GrPaint::kTotalStages,
199 }; 199 };
200 GrAssert(!drawState->isStageEnabled(kPathMaskStage));
201 drawState->createTextureEffect(kPathMaskStage, texture, SkMatrix::I());
202 SkScalar w = SkIntToScalar(rect.width());
203 SkScalar h = SkIntToScalar(rect.height());
204 GrRect maskRect = GrRect::MakeWH(w / texture->width(),
205 h / texture->height());
206 200
207 GrRect dstRect = GrRect::MakeLTRB( 201 GrRect dstRect = GrRect::MakeLTRB(
208 SK_Scalar1 * rect.fLeft, 202 SK_Scalar1 * rect.fLeft,
209 SK_Scalar1 * rect.fTop, 203 SK_Scalar1 * rect.fTop,
210 SK_Scalar1 * rect.fRight, 204 SK_Scalar1 * rect.fRight,
211 SK_Scalar1 * rect.fBottom); 205 SK_Scalar1 * rect.fBottom);
212 target->drawRect(dstRect, NULL, &maskRect, NULL, kPathMaskStage); 206
207 // We want to use device coords to compute the texture coordinates. We set o ur matrix to be
208 // equal to the view matrix followed by a translation so that the top-left o f the device bounds
209 // maps to 0,0, and then a scaling matrix to normalized coords. We apply thi s matrix to the
210 // vertex positions rather than local coords.
211 SkMatrix maskMatrix;
212 maskMatrix.setIDiv(texture->width(), texture->height());
213 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop ));
214 maskMatrix.preConcat(drawState->getViewMatrix());
215
216 GrAssert(!drawState->isStageEnabled(kPathMaskStage));
217 drawState->setEffect(kPathMaskStage,
218 GrSimpleTextureEffect::Create(texture,
219 maskMatrix,
220 false,
221 GrEffect::kPosition_Coord sType))->unref();
222
223 target->drawSimpleRect(dstRect);
213 drawState->disableStage(kPathMaskStage); 224 drawState->disableStage(kPathMaskStage);
214 } 225 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698