blob: 8c44e9f1fd1794d7caf786a32093295baabd99c2 [file] [log] [blame]
humper@google.comb0889472013-07-09 21:37:14 +00001/*
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
bungeman7403d872015-08-04 14:56:53 -07008#include "SkBitmapFilter.h"
humper@google.comb0889472013-07-09 21:37:14 +00009#include "SkRTConf.h"
bungeman7403d872015-08-04 14:56:53 -070010#include "SkTypes.h"
11
12#include <string.h>
humper@google.comb0889472013-07-09 21:37:14 +000013
humper@google.com138ebc32013-07-19 20:20:04 +000014// These are the per-scanline callbacks that are used when we must resort to
15// resampling an image as it is blitted. Typically these are used only when
16// the image is rotated or has some other complex transformation applied.
17// Scaled images will usually be rescaled directly before rasterization.
18
humper@google.com138ebc32013-07-19 20:20:04 +000019SK_CONF_DECLARE(const char *, c_bitmapFilter, "bitmap.filter", "mitchell", "Which scanline bitmap filter to use [mitchell, lanczos, hamming, gaussian, triangle, box]");
skia.committer@gmail.com9e1ec1a2013-07-10 07:00:58 +000020
humper@google.com138ebc32013-07-19 20:20:04 +000021SkBitmapFilter *SkBitmapFilter::Allocate() {
humper@google.comb0889472013-07-09 21:37:14 +000022 if (!strcmp(c_bitmapFilter, "mitchell")) {
23 return SkNEW_ARGS(SkMitchellFilter,(1.f/3.f,1.f/3.f));
humper@google.com138ebc32013-07-19 20:20:04 +000024 } else if (!strcmp(c_bitmapFilter, "lanczos")) {
25 return SkNEW(SkLanczosFilter);
26 } else if (!strcmp(c_bitmapFilter, "hamming")) {
27 return SkNEW(SkHammingFilter);
humper@google.comb0889472013-07-09 21:37:14 +000028 } else if (!strcmp(c_bitmapFilter, "gaussian")) {
29 return SkNEW_ARGS(SkGaussianFilter,(2));
30 } else if (!strcmp(c_bitmapFilter, "triangle")) {
31 return SkNEW(SkTriangleFilter);
32 } else if (!strcmp(c_bitmapFilter, "box")) {
33 return SkNEW(SkBoxFilter);
34 } else {
mtklein@google.com330313a2013-08-22 15:37:26 +000035 SkDEBUGFAIL("Unknown filter type");
humper@google.comb0889472013-07-09 21:37:14 +000036 }
skia.committer@gmail.com9e1ec1a2013-07-10 07:00:58 +000037
humper@google.comb0889472013-07-09 21:37:14 +000038 return NULL;
39}
40