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

Side by Side Diff: src/core/SkBitmapProcShader.cpp

Issue 278963002: add localmatrix parameter to shader's asNewEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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/core/SkBitmapProcShader.h ('k') | src/core/SkLocalMatrixShader.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 static SkScalar get_combined_min_stretch(const SkMatrix& viewMatrix, const SkMat rix& localMatrix) { 386 static SkScalar get_combined_min_stretch(const SkMatrix& viewMatrix, const SkMat rix& localMatrix) {
387 if (localMatrix.isIdentity()) { 387 if (localMatrix.isIdentity()) {
388 return viewMatrix.getMinStretch(); 388 return viewMatrix.getMinStretch();
389 } else { 389 } else {
390 SkMatrix combined; 390 SkMatrix combined;
391 combined.setConcat(viewMatrix, localMatrix); 391 combined.setConcat(viewMatrix, localMatrix);
392 return combined.getMinStretch(); 392 return combined.getMinStretch();
393 } 393 }
394 } 394 }
395 395
396 GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint) const { 396 GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
397 const SkMatrix* localMatrix) const {
397 SkMatrix matrix; 398 SkMatrix matrix;
398 matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); 399 matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
399 400
400 SkMatrix lmInverse; 401 SkMatrix lmInverse;
401 if (!this->getLocalMatrix().invert(&lmInverse)) { 402 if (!this->getLocalMatrix().invert(&lmInverse)) {
402 return NULL; 403 return NULL;
403 } 404 }
405 if (localMatrix) {
406 SkMatrix inv;
407 if (!localMatrix->invert(&inv)) {
408 return NULL;
409 }
410 lmInverse.postConcat(inv);
411 }
404 matrix.preConcat(lmInverse); 412 matrix.preConcat(lmInverse);
405 413
406 SkShader::TileMode tm[] = { 414 SkShader::TileMode tm[] = {
407 (TileMode)fTileModeX, 415 (TileMode)fTileModeX,
408 (TileMode)fTileModeY, 416 (TileMode)fTileModeY,
409 }; 417 };
410 418
411 // Must set wrap and filter on the sampler before requesting a texture. In t wo places below 419 // Must set wrap and filter on the sampler before requesting a texture. In t wo places below
412 // we check the matrix scale factors to determine how to interpret the filte r quality setting. 420 // we check the matrix scale factors to determine how to interpret the filte r quality setting.
413 // This completely ignores the complexity of the drawVertices case where exp licit local coords 421 // This completely ignores the complexity of the drawVertices case where exp licit local coords
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 GrEffectRef* effect = NULL; 472 GrEffectRef* effect = NULL;
465 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { 473 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) {
466 effect = GrBicubicEffect::Create(texture, matrix, tm); 474 effect = GrBicubicEffect::Create(texture, matrix, tm);
467 } else { 475 } else {
468 effect = GrSimpleTextureEffect::Create(texture, matrix, params); 476 effect = GrSimpleTextureEffect::Create(texture, matrix, params);
469 } 477 }
470 GrUnlockAndUnrefCachedBitmapTexture(texture); 478 GrUnlockAndUnrefCachedBitmapTexture(texture);
471 return effect; 479 return effect;
472 } 480 }
473 #endif 481 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkLocalMatrixShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698