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

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

Issue 754083002: Add Sk prefix to CreateBitmapShader. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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/SkDraw.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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 static bool bitmapIsTooBig(const SkBitmap& bm) { 330 static bool bitmapIsTooBig(const SkBitmap& bm) {
331 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it 331 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it
332 // communicates between its matrix-proc and its sampler-proc. Until we can 332 // communicates between its matrix-proc and its sampler-proc. Until we can
333 // widen that, we have to reject bitmaps that are larger. 333 // widen that, we have to reject bitmaps that are larger.
334 // 334 //
335 const int maxSize = 65535; 335 const int maxSize = 65535;
336 336
337 return bm.width() > maxSize || bm.height() > maxSize; 337 return bm.width() > maxSize || bm.height() > maxSize;
338 } 338 }
339 339
340 SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx, 340 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx,
341 SkShader::TileMode tmy, const SkMatrix* localMatrix, SkTBlitterAllocator * allocator) { 341 SkShader::TileMode tmy, const SkMatrix* localMatr ix,
342 SkTBlitterAllocator* allocator) {
342 SkShader* shader; 343 SkShader* shader;
343 SkColor color; 344 SkColor color;
344 if (src.isNull() || bitmapIsTooBig(src)) { 345 if (src.isNull() || bitmapIsTooBig(src)) {
345 if (NULL == allocator) { 346 if (NULL == allocator) {
346 shader = SkNEW(SkEmptyShader); 347 shader = SkNEW(SkEmptyShader);
347 } else { 348 } else {
348 shader = allocator->createT<SkEmptyShader>(); 349 shader = allocator->createT<SkEmptyShader>();
349 } 350 }
350 } 351 }
351 else if (canUseColorShader(src, &color)) { 352 else if (canUseColorShader(src, &color)) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 460
460 } 461 }
461 GrTextureParams params(tm, textureFilterMode); 462 GrTextureParams params(tm, textureFilterMode);
462 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap , &params)); 463 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap , &params));
463 464
464 if (!texture) { 465 if (!texture) {
465 SkErrorInternals::SetError( kInternalError_SkError, 466 SkErrorInternals::SetError( kInternalError_SkError,
466 "Couldn't convert bitmap to texture."); 467 "Couldn't convert bitmap to texture.");
467 return false; 468 return false;
468 } 469 }
469 470
470 *paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ? 471 *paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ?
471 SkColor2GrColor(paint.getColor() ) : 472 SkColor2GrColor(paint.getColor() ) :
472 SkColor2GrColorJustAlpha(paint.g etColor()); 473 SkColor2GrColorJustAlpha(paint.g etColor());
473 474
474 if (useBicubic) { 475 if (useBicubic) {
475 *fp = GrBicubicEffect::Create(texture, matrix, tm); 476 *fp = GrBicubicEffect::Create(texture, matrix, tm);
476 } else { 477 } else {
477 *fp = GrSimpleTextureEffect::Create(texture, matrix, params); 478 *fp = GrSimpleTextureEffect::Create(texture, matrix, params);
478 } 479 }
479 480
480 return true; 481 return true;
481 } 482 }
482 483
483 #else 484 #else
484 485
485 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix*, GrColor*, 486 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix*, GrColor*,
486 GrFragmentProcessor**) const { 487 GrFragmentProcessor**) const {
487 SkDEBUGFAIL("Should not call in GPU-less build"); 488 SkDEBUGFAIL("Should not call in GPU-less build");
488 return false; 489 return false;
489 } 490 }
490 491
491 #endif 492 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698