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

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

Issue 1313573005: Revert of Change SkShader;asFragmentProcessor signature to no longer take skpaint\grcolor* (Closed) Base URL: https://skia.googlesource.com/skia.git@things
Patch Set: Created 5 years, 3 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
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkColorShader.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkErrorInternals.h" 11 #include "SkErrorInternals.h"
12 #include "SkPixelRef.h" 12 #include "SkPixelRef.h"
13 #include "SkReadBuffer.h" 13 #include "SkReadBuffer.h"
14 #include "SkWriteBuffer.h" 14 #include "SkWriteBuffer.h"
15 15
16 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
17 #include "effects/GrBicubicEffect.h" 17 #include "effects/GrBicubicEffect.h"
18 #include "effects/GrExtractAlphaFragmentProcessor.h"
19 #include "effects/GrSimpleTextureEffect.h" 18 #include "effects/GrSimpleTextureEffect.h"
20 #endif 19 #endif
21 20
22 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo de tmy, 21 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo de tmy,
23 const SkMatrix* localMatrix) 22 const SkMatrix* localMatrix)
24 : INHERITED(localMatrix) { 23 : INHERITED(localMatrix) {
25 fRawBitmap = src; 24 fRawBitmap = src;
26 fTileModeX = (uint8_t)tmx; 25 fTileModeX = (uint8_t)tmx;
27 fTileModeY = (uint8_t)tmy; 26 fTileModeY = (uint8_t)tmy;
28 } 27 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 #endif 346 #endif
348 347
349 /////////////////////////////////////////////////////////////////////////////// 348 ///////////////////////////////////////////////////////////////////////////////
350 349
351 #if SK_SUPPORT_GPU 350 #if SK_SUPPORT_GPU
352 351
353 #include "GrTextureAccess.h" 352 #include "GrTextureAccess.h"
354 #include "SkGr.h" 353 #include "SkGr.h"
355 #include "effects/GrSimpleTextureEffect.h" 354 #include "effects/GrSimpleTextureEffect.h"
356 355
357 const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co ntext, 356 bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
358 const SkMatrix& viewM, const SkMatr ix* localMatrix, 357 const SkMatrix& viewM,
359 SkFilterQuality filterQuality, 358 const SkMatrix* localMatrix, GrColo r* paintColor,
360 GrProcessorDataManager* procDataMan ager) const { 359 GrProcessorDataManager* procDataMan ager,
360 GrFragmentProcessor** fp) const {
361 SkMatrix matrix; 361 SkMatrix matrix;
362 matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); 362 matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
363 363
364 SkMatrix lmInverse; 364 SkMatrix lmInverse;
365 if (!this->getLocalMatrix().invert(&lmInverse)) { 365 if (!this->getLocalMatrix().invert(&lmInverse)) {
366 return nullptr; 366 return false;
367 } 367 }
368 if (localMatrix) { 368 if (localMatrix) {
369 SkMatrix inv; 369 SkMatrix inv;
370 if (!localMatrix->invert(&inv)) { 370 if (!localMatrix->invert(&inv)) {
371 return nullptr; 371 return false;
372 } 372 }
373 lmInverse.postConcat(inv); 373 lmInverse.postConcat(inv);
374 } 374 }
375 matrix.preConcat(lmInverse); 375 matrix.preConcat(lmInverse);
376 376
377 SkShader::TileMode tm[] = { 377 SkShader::TileMode tm[] = {
378 (TileMode)fTileModeX, 378 (TileMode)fTileModeX,
379 (TileMode)fTileModeY, 379 (TileMode)fTileModeY,
380 }; 380 };
381 381
382 // Must set wrap and filter on the sampler before requesting a texture. In t wo places below 382 // Must set wrap and filter on the sampler before requesting a texture. In t wo places below
383 // we check the matrix scale factors to determine how to interpret the filte r quality setting. 383 // we check the matrix scale factors to determine how to interpret the filte r quality setting.
384 // This completely ignores the complexity of the drawVertices case where exp licit local coords 384 // This completely ignores the complexity of the drawVertices case where exp licit local coords
385 // are provided by the caller. 385 // are provided by the caller.
386 bool doBicubic; 386 bool doBicubic;
387 GrTextureParams::FilterMode textureFilterMode = 387 GrTextureParams::FilterMode textureFilterMode =
388 GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocal Matrix(), 388 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewM, thi s->getLocalMatrix(),
389 &doBicubic); 389 &doBicubic);
390 GrTextureParams params(tm, textureFilterMode); 390 GrTextureParams params(tm, textureFilterMode);
391 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap , &params)); 391 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap , &params));
392 392
393 if (!texture) { 393 if (!texture) {
394 SkErrorInternals::SetError( kInternalError_SkError, 394 SkErrorInternals::SetError( kInternalError_SkError,
395 "Couldn't convert bitmap to texture."); 395 "Couldn't convert bitmap to texture.");
396 return nullptr; 396 return false;
397 } 397 }
398 398
399 SkAutoTUnref<GrFragmentProcessor> inner; 399 *paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ?
400 SkColor2GrColor(paint.getColor() ) :
401 SkColor2GrColorJustAlpha(paint.g etColor());
402
400 if (doBicubic) { 403 if (doBicubic) {
401 inner.reset(GrBicubicEffect::Create(procDataManager, texture, matrix, tm )); 404 *fp = GrBicubicEffect::Create(procDataManager, texture, matrix, tm);
402 } else { 405 } else {
403 inner.reset(GrSimpleTextureEffect::Create(procDataManager, texture, matr ix, params)); 406 *fp = GrSimpleTextureEffect::Create(procDataManager, texture, matrix, pa rams);
404 } 407 }
405 408
406 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { 409 return true;
407 return SkRef(inner.get()); 410 }
408 } 411
409 return GrExtractAlphaFragmentProcessor::Create(inner); 412 #else
413
414 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix&,
415 const SkMatrix*, GrColor*, GrProces sorDataManager*,
416 GrFragmentProcessor**) const {
417 SkDEBUGFAIL("Should not call in GPU-less build");
418 return false;
410 } 419 }
411 420
412 #endif 421 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkColorShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698