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

Side by Side Diff: Source/platform/graphics/skia/NativeImageSkia.h

Issue 328453004: Replace ResamplingMode with InterpolationQuality. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: backpedal Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 class SkMatrix; 45 class SkMatrix;
46 class SkPaint; 46 class SkPaint;
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 class FloatPoint; 50 class FloatPoint;
51 class FloatRect; 51 class FloatRect;
52 class FloatSize; 52 class FloatSize;
53 class GraphicsContext; 53 class GraphicsContext;
54 54
55 // Used by computeResamplingMode to tell how bitmaps should be resampled.
56 enum ResamplingMode {
57 // Nearest neighbor resampling. Used when we detect that the page is
58 // trying to make a pattern by stretching a small bitmap very large.
59 NoResampling,
60
61 // Default skia resampling. Used for large growing of images where high
62 // quality resampling doesn't get us very much except a slowdown.
63 LinearResampling,
64
65 // LinearResampling for upscaling. Mipmapping for downscaling.
66 LinearWithMipmapsResampling,
67
68 // High quality resampling.
69 AwesomeResampling,
70 };
71
72 // This object is used as the "native image" in our port. When WebKit uses 55 // This object is used as the "native image" in our port. When WebKit uses
73 // PassNativeImagePtr / NativeImagePtr, it is a smart pointer to this type. 56 // PassNativeImagePtr / NativeImagePtr, it is a smart pointer to this type.
74 // It has an SkBitmap, and also stores a cached resized image. 57 // It has an SkBitmap, and also stores a cached resized image.
75 class PLATFORM_EXPORT NativeImageSkia : public RefCounted<NativeImageSkia> { 58 class PLATFORM_EXPORT NativeImageSkia : public RefCounted<NativeImageSkia> {
76 public: 59 public:
77 static PassRefPtr<NativeImageSkia> create() 60 static PassRefPtr<NativeImageSkia> create()
78 { 61 {
79 return adoptRef(new NativeImageSkia()); 62 return adoptRef(new NativeImageSkia());
80 } 63 }
81 64
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // result of subsequent calls. 145 // result of subsequent calls.
163 // 146 //
164 // On the one hand, if only a small subset is desired, then we will waste a 147 // On the one hand, if only a small subset is desired, then we will waste a
165 // lot of time resampling the entire thing, so we only want to do exactly 148 // lot of time resampling the entire thing, so we only want to do exactly
166 // what's required. On the other hand, resampling the entire bitmap is 149 // what's required. On the other hand, resampling the entire bitmap is
167 // better if we're going to be using it more than once (like a bitmap 150 // better if we're going to be using it more than once (like a bitmap
168 // scrolling on and off the screen. Since we only cache when doing the 151 // scrolling on and off the screen. Since we only cache when doing the
169 // entire thing, it's best to just do it up front. 152 // entire thing, it's best to just do it up front.
170 bool shouldCacheResampling(const SkISize& scaledImageSize, const SkIRect& sc aledImageSubset) const; 153 bool shouldCacheResampling(const SkISize& scaledImageSize, const SkIRect& sc aledImageSubset) const;
171 154
172 ResamplingMode computeResamplingMode(const SkMatrix&, float srcWidth, float srcHeight, float destWidth, float destHeight) const; 155 InterpolationQuality computeInterpolationQuality(const SkMatrix&, float srcW idth, float srcHeight, float destWidth, float destHeight) const;
173 SkBitmap extractScaledImageFragment(const SkRect& srcRect, float scaleX, flo at scaleY, SkRect* scaledSrcRect) const; 156 SkBitmap extractScaledImageFragment(const SkRect& srcRect, float scaleX, flo at scaleY, SkRect* scaledSrcRect) const;
174 void drawResampledBitmap(GraphicsContext*, SkPaint&, const SkRect& srcRect, const SkRect& destRect) const; 157 void drawResampledBitmap(GraphicsContext*, SkPaint&, const SkRect& srcRect, const SkRect& destRect) const;
175 158
176 // The original image. 159 // The original image.
177 SkBitmap m_image; 160 SkBitmap m_image;
178 161
179 // The cached bitmap fragment. This is a subset of the scaled version of 162 // The cached bitmap fragment. This is a subset of the scaled version of
180 // |m_image|. empty() returns true if there is no cached image. 163 // |m_image|. empty() returns true if there is no cached image.
181 mutable SkBitmap m_resizedImage; 164 mutable SkBitmap m_resizedImage;
182 165
183 // References how many times that the image size has been requested for 166 // References how many times that the image size has been requested for
184 // the last size. 167 // the last size.
185 // 168 //
186 // Every time we get a call to shouldCacheResampling, if it matches the 169 // Every time we get a call to shouldCacheResampling, if it matches the
187 // m_cachedImageInfo, we'll increment the counter, and if not, we'll reset 170 // m_cachedImageInfo, we'll increment the counter, and if not, we'll reset
188 // the counter and save the dimensions. 171 // the counter and save the dimensions.
189 // 172 //
190 // This allows us to see if many requests have been made for the same 173 // This allows us to see if many requests have been made for the same
191 // resized image, we know that we should probably cache it, even if all of 174 // resized image, we know that we should probably cache it, even if all of
192 // those requests individually are small and would not otherwise be cached. 175 // those requests individually are small and would not otherwise be cached.
193 // 176 //
194 // We also track scaling information and destination subset for the scaled 177 // We also track scaling information and destination subset for the scaled
195 // image. See comments for ImageResourceInfo. 178 // image. See comments for ImageResourceInfo.
196 mutable ImageResourceInfo m_cachedImageInfo; 179 mutable ImageResourceInfo m_cachedImageInfo;
197 mutable int m_resizeRequests; 180 mutable int m_resizeRequests;
198 }; 181 };
199 182
200 } 183 }
201 #endif // NativeImageSkia_h 184 #endif // NativeImageSkia_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsTypes.h ('k') | Source/platform/graphics/skia/NativeImageSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698