chromeos: bluetooth: add BluetoothInputClient
[chromium-blink-merge.git] / skia / ext / image_operations.h
blob11a86390fe6fcece92e5ef52a9e68973dfc3cf78
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SKIA_EXT_IMAGE_OPERATIONS_H_
6 #define SKIA_EXT_IMAGE_OPERATIONS_H_
7 #pragma once
9 #include "third_party/skia/include/core/SkTypes.h"
11 class SkBitmap;
12 struct SkIRect;
14 namespace skia {
16 class SK_API ImageOperations {
17 public:
18 enum ResizeMethod {
20 // Quality Methods
22 // Those enumeration values express a desired quality/speed tradeoff.
23 // They are translated into an algorithm-specific method that depends
24 // on the capabilities (CPU, GPU) of the underlying platform.
25 // It is possible for all three methods to be mapped to the same
26 // algorithm on a given platform.
28 // Good quality resizing. Fastest resizing with acceptable visual quality.
29 // This is typically intended for use during interactive layouts
30 // where slower platforms may want to trade image quality for large
31 // increase in resizing performance.
33 // For example the resizing implementation may devolve to linear
34 // filtering if this enables GPU acceleration to be used.
36 // Note that the underlying resizing method may be determined
37 // on the fly based on the parameters for a given resize call.
38 // For example an implementation using a GPU-based linear filter
39 // in the common case may still use a higher-quality software-based
40 // filter in cases where using the GPU would actually be slower - due
41 // to too much latency - or impossible - due to image format or size
42 // constraints.
43 RESIZE_GOOD,
45 // Medium quality resizing. Close to high quality resizing (better
46 // than linear interpolation) with potentially some quality being
47 // traded-off for additional speed compared to RESIZE_BEST.
49 // This is intended, for example, for generation of large thumbnails
50 // (hundreds of pixels in each dimension) from large sources, where
51 // a linear filter would produce too many artifacts but where
52 // a RESIZE_HIGH might be too costly time-wise.
53 RESIZE_BETTER,
55 // High quality resizing. The algorithm is picked to favor image quality.
56 RESIZE_BEST,
59 // Algorithm-specific enumerations
62 // Box filter. This is a weighted average of all of the pixels touching
63 // the destination pixel. For enlargement, this is nearest neighbor.
65 // You probably don't want this, it is here for testing since it is easy to
66 // compute. Use RESIZE_LANCZOS3 instead.
67 RESIZE_BOX,
69 // 1-cycle Hamming filter. This is tall is the middle and falls off towards
70 // the window edges but without going to 0. This is about 40% faster than
71 // a 2-cycle Lanczos.
72 RESIZE_HAMMING1,
74 // 2-cycle Lanczos filter. This is tall in the middle, goes negative on
75 // each side, then returns to zero. Does not provide as good a frequency
76 // response as a 3-cycle Lanczos but is roughly 30% faster.
77 RESIZE_LANCZOS2,
79 // 3-cycle Lanczos filter. This is tall in the middle, goes negative on
80 // each side, then oscillates 2 more times. It gives nice sharp edges.
81 RESIZE_LANCZOS3,
83 // Lanczos filter + subpixel interpolation. If subpixel rendering is not
84 // appropriate we automatically fall back to Lanczos.
85 RESIZE_SUBPIXEL,
87 // enum aliases for first and last methods by algorithm or by quality.
88 RESIZE_FIRST_QUALITY_METHOD = RESIZE_GOOD,
89 RESIZE_LAST_QUALITY_METHOD = RESIZE_BEST,
90 RESIZE_FIRST_ALGORITHM_METHOD = RESIZE_BOX,
91 RESIZE_LAST_ALGORITHM_METHOD = RESIZE_SUBPIXEL,
94 // Resizes the given source bitmap using the specified resize method, so that
95 // the entire image is (dest_size) big. The dest_subset is the rectangle in
96 // this destination image that should actually be returned.
98 // The output image will be (dest_subset.width(), dest_subset.height()). This
99 // will save work if you do not need the entire bitmap.
101 // The destination subset must be smaller than the destination image.
102 static SkBitmap Resize(const SkBitmap& source,
103 ResizeMethod method,
104 int dest_width, int dest_height,
105 const SkIRect& dest_subset);
107 // Alternate version for resizing and returning the entire bitmap rather than
108 // a subset.
109 static SkBitmap Resize(const SkBitmap& source,
110 ResizeMethod method,
111 int dest_width, int dest_height);
113 private:
114 ImageOperations(); // Class for scoping only.
116 // Supports all methods except RESIZE_SUBPIXEL.
117 static SkBitmap ResizeBasic(const SkBitmap& source,
118 ResizeMethod method,
119 int dest_width, int dest_height,
120 const SkIRect& dest_subset);
122 // Subpixel renderer.
123 static SkBitmap ResizeSubpixel(const SkBitmap& source,
124 int dest_width, int dest_height,
125 const SkIRect& dest_subset);
128 } // namespace skia
130 #endif // SKIA_EXT_IMAGE_OPERATIONS_H_