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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 1285283002: Refactor helper function for SkBitmapShader to GrFragmentProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/gpu/SkGpuDevice.cpp ('k') | no next file » | 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 2010 Google Inc. 2 * Copyright 2010 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 "SkGr.h" 8 #include "SkGr.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
11 #include "GrDrawContext.h" 11 #include "GrDrawContext.h"
12 #include "GrXferProcessor.h" 12 #include "GrXferProcessor.h"
13 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
14 #include "SkConfig8888.h" 14 #include "SkConfig8888.h"
15 #include "SkCanvas.h" 15 #include "SkCanvas.h"
16 #include "SkData.h" 16 #include "SkData.h"
17 #include "SkErrorInternals.h" 17 #include "SkErrorInternals.h"
18 #include "SkGrPixelRef.h" 18 #include "SkGrPixelRef.h"
19 #include "SkMessageBus.h" 19 #include "SkMessageBus.h"
20 #include "SkPixelRef.h" 20 #include "SkPixelRef.h"
21 #include "SkResourceCache.h" 21 #include "SkResourceCache.h"
22 #include "SkTextureCompressor.h" 22 #include "SkTextureCompressor.h"
23 #include "SkYUVPlanesCache.h" 23 #include "SkYUVPlanesCache.h"
24 #include "effects/GrBicubicEffect.h"
24 #include "effects/GrDitherEffect.h" 25 #include "effects/GrDitherEffect.h"
25 #include "effects/GrPorterDuffXferProcessor.h" 26 #include "effects/GrPorterDuffXferProcessor.h"
26 #include "effects/GrYUVtoRGBEffect.h" 27 #include "effects/GrYUVtoRGBEffect.h"
27 28
28 #ifndef SK_IGNORE_ETC1_SUPPORT 29 #ifndef SK_IGNORE_ETC1_SUPPORT
29 # include "ktx.h" 30 # include "ktx.h"
30 # include "etc1.h" 31 # include "etc1.h"
31 #endif 32 #endif
32 33
33 /* Fill out buffer with the compressed format Ganesh expects from a colortable 34 /* Fill out buffer with the compressed format Ganesh expects from a colortable
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 } 829 }
829 return SkImageInfo::Make(w, h, ct, at); 830 return SkImageInfo::Make(w, h, ct, at);
830 } 831 }
831 832
832 833
833 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) { 834 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) {
834 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); 835 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
835 dst->setInfo(info); 836 dst->setInfo(info);
836 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); 837 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
837 } 838 }
839
840 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain tFilterQuality,
841 const SkMatrix& view M,
842 const SkMatrix& loca lM,
843 bool* doBicubic) {
844 *doBicubic = false;
845 GrTextureParams::FilterMode textureFilterMode;
846 switch (paintFilterQuality) {
847 case kNone_SkFilterQuality:
848 textureFilterMode = GrTextureParams::kNone_FilterMode;
849 break;
850 case kLow_SkFilterQuality:
851 textureFilterMode = GrTextureParams::kBilerp_FilterMode;
852 break;
853 case kMedium_SkFilterQuality: {
854 SkMatrix matrix;
855 matrix.setConcat(viewM, localM);
856 if (matrix.getMinScale() < SK_Scalar1) {
857 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
858 } else {
859 // Don't trigger MIP level generation unnecessarily.
860 textureFilterMode = GrTextureParams::kBilerp_FilterMode;
861 }
862 break;
863 }
864 case kHigh_SkFilterQuality: {
865 SkMatrix matrix;
866 matrix.setConcat(viewM, localM);
867 *doBicubic = GrBicubicEffect::ShouldUseBicubic(matrix, &textureFilte rMode);
868 break;
869 }
870 default:
871 SkErrorInternals::SetError( kInvalidPaint_SkError,
872 "Sorry, I don't understand the filtering "
873 "mode you asked for. Falling back to "
874 "MIPMaps.");
875 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
876 break;
877
878 }
879 return textureFilterMode;
880 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698