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

Side by Side Diff: src/core/SkBitmapScaler.h

Issue 1320513005: simplify bitmap scaler and cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/core/SkBitmapController.cpp ('k') | src/core/SkBitmapScaler.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 #ifndef SkBitmapScaler_DEFINED 8 #ifndef SkBitmapScaler_DEFINED
9 #define SkBitmapScaler_DEFINED 9 #define SkBitmapScaler_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkConvolver.h" 12 #include "SkConvolver.h"
13 13
14 /** \class SkBitmapScaler 14 /** \class SkBitmapScaler
15 15
16 Provides the interface for high quality image resampling. 16 Provides the interface for high quality image resampling.
17 */ 17 */
18 18
19 class SK_API SkBitmapScaler { 19 class SK_API SkBitmapScaler {
20 public: 20 public:
21 enum ResizeMethod { 21 enum ResizeMethod {
22 // Quality Methods
23 //
24 // Those enumeration values express a desired quality/speed tradeoff.
25 // They are translated into an algorithm-specific method that depends
26 // on the capabilities (CPU, GPU) of the underlying platform.
27 // It is possible for all three methods to be mapped to the same
28 // algorithm on a given platform.
29
30 // Good quality resizing. Fastest resizing with acceptable visual qualit y.
31 // This is typically intended for use during interactive layouts
32 // where slower platforms may want to trade image quality for large
33 // increase in resizing performance.
34 //
35 // For example the resizing implementation may devolve to linear
36 // filtering if this enables GPU acceleration to be used.
37 //
38 // Note that the underlying resizing method may be determined
39 // on the fly based on the parameters for a given resize call.
40 // For example an implementation using a GPU-based linear filter
41 // in the common case may still use a higher-quality software-based
42 // filter in cases where using the GPU would actually be slower - due
43 // to too much latency - or impossible - due to image format or size
44 // constraints.
45 RESIZE_GOOD,
46
47 // Medium quality resizing. Close to high quality resizing (better
48 // than linear interpolation) with potentially some quality being
49 // traded-off for additional speed compared to RESIZE_BEST.
50 //
51 // This is intended, for example, for generation of large thumbnails
52 // (hundreds of pixels in each dimension) from large sources, where
53 // a linear filter would produce too many artifacts but where
54 // a RESIZE_HIGH might be too costly time-wise.
55 RESIZE_BETTER,
56
57 // High quality resizing. The algorithm is picked to favor image quality .
58 RESIZE_BEST,
59
60 //
61 // Algorithm-specific enumerations
62 //
63
64 // Box filter. This is a weighted average of all of the pixels touching
65 // the destination pixel. For enlargement, this is nearest neighbor.
66 //
67 // You probably don't want this, it is here for testing since it is easy to
68 // compute. Use RESIZE_LANCZOS3 instead.
69 RESIZE_BOX, 22 RESIZE_BOX,
70 RESIZE_TRIANGLE, 23 RESIZE_TRIANGLE,
71 RESIZE_LANCZOS3, 24 RESIZE_LANCZOS3,
72 RESIZE_HAMMING, 25 RESIZE_HAMMING,
73 RESIZE_MITCHELL, 26 RESIZE_MITCHELL,
74 27
75 // enum aliases for first and last methods by algorithm or by quality. 28 RESIZE_FirstMethod = RESIZE_BOX,
76 RESIZE_FIRST_QUALITY_METHOD = RESIZE_GOOD, 29 RESIZE_LastMethod = RESIZE_MITCHELL,
77 RESIZE_LAST_QUALITY_METHOD = RESIZE_BEST,
78 RESIZE_FIRST_ALGORITHM_METHOD = RESIZE_BOX,
79 RESIZE_LAST_ALGORITHM_METHOD = RESIZE_MITCHELL,
80 }; 30 };
81 31
82 static bool Resize(SkBitmap* result, const SkPixmap& src, ResizeMethod metho d, 32 static bool Resize(SkBitmap* result, const SkPixmap& src, ResizeMethod metho d,
83 float dest_width, float dest_height, SkBitmap::Allocator* = nullptr); 33 int dest_width, int dest_height, SkBitmap::Allocator* = n ullptr);
84 34
85 /** Platforms can also optionally overwrite the convolution functions 35 /** Platforms can also optionally overwrite the convolution functions
86 if we have SIMD versions of them. 36 if we have SIMD versions of them.
87 */ 37 */
88 38
89 static void PlatformConvolutionProcs(SkConvolutionProcs*); 39 static void PlatformConvolutionProcs(SkConvolutionProcs*);
90 }; 40 };
91 41
92 #endif 42 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapController.cpp ('k') | src/core/SkBitmapScaler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698