| OLD | NEW |
| 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 | 9 |
| 10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return NULL; | 340 return NULL; |
| 341 } | 341 } |
| 342 | 342 |
| 343 helper.toTexture(texture); | 343 helper.toTexture(texture); |
| 344 | 344 |
| 345 return texture; | 345 return texture; |
| 346 } | 346 } |
| 347 | 347 |
| 348 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, | 348 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, |
| 349 GrDrawTarget* target, | 349 GrDrawTarget* target, |
| 350 GrDrawState* drawState, |
| 350 const SkIRect& rect) { | 351 const SkIRect& rect) { |
| 351 GrDrawState* drawState = target->drawState(); | |
| 352 | |
| 353 GrDrawState::AutoViewMatrixRestore avmr; | 352 GrDrawState::AutoViewMatrixRestore avmr; |
| 354 if (!avmr.setIdentity(drawState)) { | 353 if (!avmr.setIdentity(drawState)) { |
| 355 return; | 354 return; |
| 356 } | 355 } |
| 357 GrDrawState::AutoRestoreEffects are(drawState); | 356 GrDrawState::AutoRestoreEffects are(drawState); |
| 358 | 357 |
| 359 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, | 358 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, |
| 360 SK_Scalar1 * rect.fTop, | 359 SK_Scalar1 * rect.fTop, |
| 361 SK_Scalar1 * rect.fRight, | 360 SK_Scalar1 * rect.fRight, |
| 362 SK_Scalar1 * rect.fBottom); | 361 SK_Scalar1 * rect.fBottom); |
| 363 | 362 |
| 364 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be | 363 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be |
| 365 // equal to the view matrix followed by a translation so that the top-left o
f the device bounds | 364 // equal to the view matrix followed by a translation so that the top-left o
f the device bounds |
| 366 // maps to 0,0, and then a scaling matrix to normalized coords. We apply thi
s matrix to the | 365 // maps to 0,0, and then a scaling matrix to normalized coords. We apply thi
s matrix to the |
| 367 // vertex positions rather than local coords. | 366 // vertex positions rather than local coords. |
| 368 SkMatrix maskMatrix; | 367 SkMatrix maskMatrix; |
| 369 maskMatrix.setIDiv(texture->width(), texture->height()); | 368 maskMatrix.setIDiv(texture->width(), texture->height()); |
| 370 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); | 369 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); |
| 371 maskMatrix.preConcat(drawState->getViewMatrix()); | 370 maskMatrix.preConcat(drawState->getViewMatrix()); |
| 372 | 371 |
| 373 drawState->addCoverageProcessor( | 372 drawState->addCoverageProcessor( |
| 374 GrSimpleTextureEffect::Create(texture, | 373 GrSimpleTextureEffect::Create(texture, |
| 375 maskMatrix, | 374 maskMatrix, |
| 376 GrTextureParams::kNone_Fi
lterMode, | 375 GrTextureParams::kNone_Fi
lterMode, |
| 377 kPosition_GrCoordSet))->u
nref(); | 376 kPosition_GrCoordSet))->u
nref(); |
| 378 | 377 |
| 379 target->drawSimpleRect(dstRect); | 378 target->drawSimpleRect(drawState, dstRect); |
| 380 } | 379 } |
| OLD | NEW |