1/* 2 * Copyright 2013 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#include "SkErrorInternals.h" 9#include "SkConvolver.h" 10#include "SkBitmapProcState.h" 11#include "SkBitmap.h" 12#include "SkColor.h" 13#include "SkColorPriv.h" 14#include "SkConvolver.h" 15#include "SkUnPreMultiply.h" 16#include "SkShader.h" 17#include "SkRTConf.h" 18#include "SkMath.h" 19 20// These are the per-scanline callbacks that are used when we must resort to 21// resampling an image as it is blitted. Typically these are used only when 22// the image is rotated or has some other complex transformation applied. 23// Scaled images will usually be rescaled directly before rasterization. 24 25SK_CONF_DECLARE(const char *, c_bitmapFilter, "bitmap.filter", "mitchell", "Which scanline bitmap filter to use [mitchell, lanczos, hamming, gaussian, triangle, box]"); 26 27SkBitmapFilter *SkBitmapFilter::Allocate() { 28 if (!strcmp(c_bitmapFilter, "mitchell")) { 29 return SkNEW_ARGS(SkMitchellFilter,(1.f/3.f,1.f/3.f)); 30 } else if (!strcmp(c_bitmapFilter, "lanczos")) { 31 return SkNEW(SkLanczosFilter); 32 } else if (!strcmp(c_bitmapFilter, "hamming")) { 33 return SkNEW(SkHammingFilter); 34 } else if (!strcmp(c_bitmapFilter, "gaussian")) { 35 return SkNEW_ARGS(SkGaussianFilter,(2)); 36 } else if (!strcmp(c_bitmapFilter, "triangle")) { 37 return SkNEW(SkTriangleFilter); 38 } else if (!strcmp(c_bitmapFilter, "box")) { 39 return SkNEW(SkBoxFilter); 40 } else { 41 SkDEBUGFAIL("Unknown filter type"); 42 } 43 44 return NULL; 45} 46 47