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

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

Issue 23779003: first cut at HQ GPU scaling; refactored existing bicubic scaler (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: final version for trybots Created 7 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkError.h ('k') | src/effects/SkBicubicImageFilter.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 "SkBitmapProcShader.h"
9 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
10 #include "SkFlattenableBuffers.h" 9 #include "SkFlattenableBuffers.h"
11 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
12 #include "SkErrorInternals.h" 11 #include "SkErrorInternals.h"
12 #include "SkBitmapProcShader.h"
13
14 #include "effects/GrSimpleTextureEffect.h"
15 #include "effects/GrBicubicEffect.h"
13 16
14 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { 17 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) {
15 switch (bm.config()) { 18 switch (bm.config()) {
16 case SkBitmap::kA8_Config: 19 case SkBitmap::kA8_Config:
17 case SkBitmap::kRGB_565_Config: 20 case SkBitmap::kRGB_565_Config:
18 case SkBitmap::kIndex8_Config: 21 case SkBitmap::kIndex8_Config:
19 case SkBitmap::kARGB_8888_Config: 22 case SkBitmap::kARGB_8888_Config:
20 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) 23 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx))
21 return true; 24 return true;
22 default: 25 default:
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 case SkPaint::kNone_FilterLevel: 363 case SkPaint::kNone_FilterLevel:
361 textureFilterMode = GrTextureParams::kNone_FilterMode; 364 textureFilterMode = GrTextureParams::kNone_FilterMode;
362 break; 365 break;
363 case SkPaint::kLow_FilterLevel: 366 case SkPaint::kLow_FilterLevel:
364 textureFilterMode = GrTextureParams::kBilerp_FilterMode; 367 textureFilterMode = GrTextureParams::kBilerp_FilterMode;
365 break; 368 break;
366 case SkPaint::kMedium_FilterLevel: 369 case SkPaint::kMedium_FilterLevel:
367 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 370 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
368 break; 371 break;
369 case SkPaint::kHigh_FilterLevel: 372 case SkPaint::kHigh_FilterLevel:
370 SkErrorInternals::SetError( kInvalidPaint_SkError, 373 // fall back to no filtering here; we will install another
371 "Sorry, I don't yet support high quality " 374 // shader that will do the HQ filtering.
372 "filtering on the GPU; falling back to " 375 textureFilterMode = GrTextureParams::kNone_FilterMode;
373 "MIPMaps.");
374 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
375 break; 376 break;
376 default: 377 default:
377 SkErrorInternals::SetError( kInvalidPaint_SkError, 378 SkErrorInternals::SetError( kInvalidPaint_SkError,
378 "Sorry, I don't understand the filtering " 379 "Sorry, I don't understand the filtering "
379 "mode you asked for. Falling back to " 380 "mode you asked for. Falling back to "
380 "MIPMaps."); 381 "MIPMaps.");
381 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 382 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
382 break; 383 break;
383 384
384 } 385 }
385 GrTextureParams params(tm, textureFilterMode); 386 GrTextureParams params(tm, textureFilterMode);
386 GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap, &p arams); 387 GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap, &p arams);
387 388
388 if (NULL == texture) { 389 if (NULL == texture) {
389 SkDebugf("Couldn't convert bitmap to texture.\n"); 390 SkErrorInternals::SetError( kInternalError_SkError,
391 "Couldn't convert bitmap to texture.");
390 return NULL; 392 return NULL;
391 } 393 }
392 394
393 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params) ; 395 GrEffectRef* effect = NULL;
396 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) {
397 effect = GrBicubicEffect::Create(texture, matrix, params);
398 } else {
399 effect = GrSimpleTextureEffect::Create(texture, matrix, params);
400 }
394 GrUnlockAndUnrefCachedBitmapTexture(texture); 401 GrUnlockAndUnrefCachedBitmapTexture(texture);
395 return effect; 402 return effect;
396 } 403 }
397 #endif 404 #endif
OLDNEW
« no previous file with comments | « include/core/SkError.h ('k') | src/effects/SkBicubicImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698