| OLD | NEW |
| 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" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 | 239 |
| 240 static GrTexture* create_texture_for_bmp(GrContext* ctx, | 240 static GrTexture* create_texture_for_bmp(GrContext* ctx, |
| 241 const GrUniqueKey& optionalKey, | 241 const GrUniqueKey& optionalKey, |
| 242 GrSurfaceDesc desc, | 242 GrSurfaceDesc desc, |
| 243 SkPixelRef* pixelRefForInvalidationNoti
fication, | 243 SkPixelRef* pixelRefForInvalidationNoti
fication, |
| 244 const void* pixels, | 244 const void* pixels, |
| 245 size_t rowBytes) { | 245 size_t rowBytes) { |
| 246 GrTexture* result = ctx->textureProvider()->createTexture(desc, true, pixels
, rowBytes); | 246 GrTexture* result = ctx->textureProvider()->createTexture(desc, true, pixels
, rowBytes); |
| 247 if (result && optionalKey.isValid()) { | 247 if (result && optionalKey.isValid()) { |
| 248 BitmapInvalidator* listener = SkNEW_ARGS(BitmapInvalidator, (optionalKey
)); | 248 BitmapInvalidator* listener = new BitmapInvalidator(optionalKey); |
| 249 pixelRefForInvalidationNotification->addGenIDChangeListener(listener); | 249 pixelRefForInvalidationNotification->addGenIDChangeListener(listener); |
| 250 ctx->textureProvider()->assignUniqueKeyToTexture(optionalKey, result); | 250 ctx->textureProvider()->assignUniqueKeyToTexture(optionalKey, result); |
| 251 } | 251 } |
| 252 return result; | 252 return result; |
| 253 } | 253 } |
| 254 | 254 |
| 255 // creates a new texture that is the input texture scaled up. If optionalKey is
valid it will be | 255 // creates a new texture that is the input texture scaled up. If optionalKey is
valid it will be |
| 256 // set on the new texture. stretch controls whether the scaling is done using ne
arest or bilerp | 256 // set on the new texture. stretch controls whether the scaling is done using ne
arest or bilerp |
| 257 // filtering and the size to stretch the texture to. | 257 // filtering and the size to stretch the texture to. |
| 258 GrTexture* stretch_texture(GrTexture* inputTexture, const Stretch& stretch, | 258 GrTexture* stretch_texture(GrTexture* inputTexture, const Stretch& stretch, |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 if (!GrPixelConfig2ColorAndProfileType(config, &ct, NULL)) { | 885 if (!GrPixelConfig2ColorAndProfileType(config, &ct, NULL)) { |
| 886 ct = kUnknown_SkColorType; | 886 ct = kUnknown_SkColorType; |
| 887 } | 887 } |
| 888 return SkImageInfo::Make(w, h, ct, at); | 888 return SkImageInfo::Make(w, h, ct, at); |
| 889 } | 889 } |
| 890 | 890 |
| 891 | 891 |
| 892 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { | 892 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { |
| 893 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); | 893 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); |
| 894 dst->setInfo(info); | 894 dst->setInfo(info); |
| 895 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); | 895 dst->setPixelRef(new SkGrPixelRef(info, src))->unref(); |
| 896 } | 896 } |
| 897 | 897 |
| 898 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, | 898 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, |
| 899 const SkMatrix& view
M, | 899 const SkMatrix& view
M, |
| 900 const SkMatrix& loca
lM, | 900 const SkMatrix& loca
lM, |
| 901 bool* doBicubic) { | 901 bool* doBicubic) { |
| 902 *doBicubic = false; | 902 *doBicubic = false; |
| 903 GrTextureParams::FilterMode textureFilterMode; | 903 GrTextureParams::FilterMode textureFilterMode; |
| 904 switch (paintFilterQuality) { | 904 switch (paintFilterQuality) { |
| 905 case kNone_SkFilterQuality: | 905 case kNone_SkFilterQuality: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 929 SkErrorInternals::SetError( kInvalidPaint_SkError, | 929 SkErrorInternals::SetError( kInvalidPaint_SkError, |
| 930 "Sorry, I don't understand the filtering
" | 930 "Sorry, I don't understand the filtering
" |
| 931 "mode you asked for. Falling back to " | 931 "mode you asked for. Falling back to " |
| 932 "MIPMaps."); | 932 "MIPMaps."); |
| 933 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 933 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 934 break; | 934 break; |
| 935 | 935 |
| 936 } | 936 } |
| 937 return textureFilterMode; | 937 return textureFilterMode; |
| 938 } | 938 } |
| OLD | NEW |