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

Side by Side Diff: skia/ext/image_operations.h

Issue 5575010: Integration of most changes from the GoogleTV project around the convolver/sc... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Fixes to address Brett's comments Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SKIA_EXT_IMAGE_OPERATIONS_H_ 5 #ifndef SKIA_EXT_IMAGE_OPERATIONS_H_
6 #define SKIA_EXT_IMAGE_OPERATIONS_H_ 6 #define SKIA_EXT_IMAGE_OPERATIONS_H_
7 #pragma once 7 #pragma once
8 8
9 class SkBitmap; 9 class SkBitmap;
10 struct SkIRect; 10 struct SkIRect;
11 11
12 namespace skia { 12 namespace skia {
13 13
14 class ImageOperations { 14 class ImageOperations {
15 public: 15 public:
16 enum ResizeMethod { 16 enum ResizeMethod {
17 //
18 // Quality Methods
19 //
20 // Those enumeration values express a desired quality/speed tradeoff.
21 // They are translated into an algorithm-specific method that depends
22 // on the capabilities (CPU, GPU) of the underlying platform.
23 // It is possible for all three methods to be mapped to the same
24 // algorithm on a given platform.
25
26 // Good quality resizing. Fastest resizing with acceptable visual quality.
27 // This is typically intended for use during interactive layouts
28 // where slower platforms may want to trade image quality for large
29 // increase in resizing performance.
30 //
31 // For example the resizing implementation may devolve to linear
32 // filtering if this enables GPU acceleration to be used.
33 //
34 // Note that the underlying resizing method may be determined
35 // on the fly based on the parameters for a given resize call.
36 // For example an implementation using a GPU-based linear filter
37 // in the common case may still use a higher-quality software-based
38 // filter in cases where using the GPU would actually be slower - due
39 // to too much latency - or impossible - due to image format or size
40 // constraints.
41 RESIZE_GOOD,
42
43 // Medium quality resizing. Close to high quality resizing (better
44 // than linear interpolation) with potentially some quality being
45 // traded-off for additional speed compared to RESIZE_BEST.
46 //
47 // This is intended, for example, for generation of large thumbnails
48 // (hundreds of pixels in each dimension) from large sources, where
49 // a linear filter would produce too many artifacts but where
50 // a RESIZE_HIGH might be too costly time-wise.
51 RESIZE_BETTER,
52
53 // High quality resizing. The algorithm is picked to favor image quality.
54 RESIZE_BEST,
55
56 //
57 // Algorithm-specific enumerations
58 //
59
17 // Box filter. This is a weighted average of all of the pixels touching 60 // Box filter. This is a weighted average of all of the pixels touching
18 // the destination pixel. For enlargement, this is nearest neighbor. 61 // the destination pixel. For enlargement, this is nearest neighbor.
19 // 62 //
20 // You probably don't want this, it is here for testing since it is easy to 63 // You probably don't want this, it is here for testing since it is easy to
21 // compute. Use RESIZE_LANCZOS3 instead. 64 // compute. Use RESIZE_LANCZOS3 instead.
22 RESIZE_BOX, 65 RESIZE_BOX,
23 66
67 // 1-cycle Hamming filter. This is tall is the middle and falls off towards
68 // the window edges but without going to 0. This is about 40% faster than
69 // a 2-cycle Lanczos.
70 RESIZE_HAMMING1,
71
72 // 2-cycle Lanczos filter. This is tall in the middle, goes negative on
brettw 2010/12/17 20:07:55 This comment looks wrong (it's the same as the 2-c
evannier 2010/12/19 00:15:03 Done. Indeed, as mentioned in the .cc, LANCZOS1 is
73 // each side, then returns to zero. Does not provide as good a frequency
74 // response as a 3-cycle Lanczos but is roughly 30% faster.
75 RESIZE_LANCZOS1,
76
77 // 2-cycle Lanczos filter. This is tall in the middle, goes negative on
78 // each side, then returns to zero. Does not provide as good a frequency
79 // response as a 3-cycle Lanczos but is roughly 30% faster.
80 RESIZE_LANCZOS2,
81
24 // 3-cycle Lanczos filter. This is tall in the middle, goes negative on 82 // 3-cycle Lanczos filter. This is tall in the middle, goes negative on
25 // each side, then oscillates 2 more times. It gives nice sharp edges. 83 // each side, then oscillates 2 more times. It gives nice sharp edges.
26 RESIZE_LANCZOS3, 84 RESIZE_LANCZOS3,
27 85
28 // Lanczos filter + subpixel interpolation. If subpixel rendering is not 86 // Lanczos filter + subpixel interpolation. If subpixel rendering is not
29 // appropriate we automatically fall back to Lanczos. 87 // appropriate we automatically fall back to Lanczos.
30 RESIZE_SUBPIXEL, 88 RESIZE_SUBPIXEL,
89
90 //
91 RESIZE_FIRST_QUALITY_METHOD = RESIZE_GOOD,
92 RESIZE_LAST_QUALITY_METHOD = RESIZE_BEST,
93 RESIZE_FIRST_ALGORITHM_METHOD = RESIZE_BOX,
94 RESIZE_LAST_ALGORITHM_METHOD = RESIZE_SUBPIXEL,
31 }; 95 };
32 96
33 // Resizes the given source bitmap using the specified resize method, so that 97 // Resizes the given source bitmap using the specified resize method, so that
34 // the entire image is (dest_size) big. The dest_subset is the rectangle in 98 // the entire image is (dest_size) big. The dest_subset is the rectangle in
35 // this destination image that should actually be returned. 99 // this destination image that should actually be returned.
36 // 100 //
37 // The output image will be (dest_subset.width(), dest_subset.height()). This 101 // The output image will be (dest_subset.width(), dest_subset.height()). This
38 // will save work if you do not need the entire bitmap. 102 // will save work if you do not need the entire bitmap.
39 // 103 //
40 // The destination subset must be smaller than the destination image. 104 // The destination subset must be smaller than the destination image.
(...skipping 19 matching lines...) Expand all
60 124
61 // Subpixel renderer. 125 // Subpixel renderer.
62 static SkBitmap ResizeSubpixel(const SkBitmap& source, 126 static SkBitmap ResizeSubpixel(const SkBitmap& source,
63 int dest_width, int dest_height, 127 int dest_width, int dest_height,
64 const SkIRect& dest_subset); 128 const SkIRect& dest_subset);
65 }; 129 };
66 130
67 } // namespace skia 131 } // namespace skia
68 132
69 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_ 133 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698