| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006,2007,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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 { | 236 { |
| 237 return fabs(value - floorf(value)) < std::numeric_limits<float>::epsilon(); | 237 return fabs(value - floorf(value)) < std::numeric_limits<float>::epsilon(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 InterpolationQuality limitInterpolationQuality(const GraphicsContext* context, I
nterpolationQuality resampling) | 240 InterpolationQuality limitInterpolationQuality(const GraphicsContext* context, I
nterpolationQuality resampling) |
| 241 { | 241 { |
| 242 return std::min(resampling, context->imageInterpolationQuality()); | 242 return std::min(resampling, context->imageInterpolationQuality()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 InterpolationQuality computeInterpolationQuality( | 245 InterpolationQuality computeInterpolationQuality( |
| 246 const SkMatrix& matrix, | |
| 247 float srcWidth, | 246 float srcWidth, |
| 248 float srcHeight, | 247 float srcHeight, |
| 249 float destWidth, | 248 float destWidth, |
| 250 float destHeight, | 249 float destHeight, |
| 251 bool isDataComplete) | 250 bool isDataComplete) |
| 252 { | 251 { |
| 253 // The percent change below which we will not resample. This usually means | 252 // The percent change below which we will not resample. This usually means |
| 254 // an off-by-one error on the web page, and just doing nearest neighbor | 253 // an off-by-one error on the web page, and just doing nearest neighbor |
| 255 // sampling is usually good enough. | 254 // sampling is usually good enough. |
| 256 const float kFractionalChangeThreshold = 0.025f; | 255 const float kFractionalChangeThreshold = 0.025f; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // is a small fraction of the original size. | 314 // is a small fraction of the original size. |
| 316 return InterpolationNone; | 315 return InterpolationNone; |
| 317 } | 316 } |
| 318 | 317 |
| 319 // When the image is not yet done loading, use linear. We don't cache the | 318 // When the image is not yet done loading, use linear. We don't cache the |
| 320 // partially resampled images, and as they come in incrementally, it causes | 319 // partially resampled images, and as they come in incrementally, it causes |
| 321 // us to have to resample the whole thing every time. | 320 // us to have to resample the whole thing every time. |
| 322 if (!isDataComplete) | 321 if (!isDataComplete) |
| 323 return InterpolationLow; | 322 return InterpolationLow; |
| 324 | 323 |
| 325 // Everything else gets resampled. | 324 // Everything else gets resampled at high quality. |
| 326 // High quality interpolation only enabled for scaling and translation. | 325 return InterpolationHigh; |
| 327 if (!(matrix.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Ma
sk))) | |
| 328 return InterpolationHigh; | |
| 329 | |
| 330 return InterpolationLow; | |
| 331 } | 326 } |
| 332 | 327 |
| 333 int clampedAlphaForBlending(float alpha) | 328 int clampedAlphaForBlending(float alpha) |
| 334 { | 329 { |
| 335 if (alpha < 0) | 330 if (alpha < 0) |
| 336 return 0; | 331 return 0; |
| 337 int roundedAlpha = roundf(alpha * 256); | 332 int roundedAlpha = roundf(alpha * 256); |
| 338 if (roundedAlpha > 256) | 333 if (roundedAlpha > 256) |
| 339 roundedAlpha = 256; | 334 roundedAlpha = 256; |
| 340 return roundedAlpha; | 335 return roundedAlpha; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 paint.setAlpha(128); | 392 paint.setAlpha(128); |
| 398 paint.setStrokeWidth(paint.getStrokeWidth() * 0.5f); | 393 paint.setStrokeWidth(paint.getStrokeWidth() * 0.5f); |
| 399 drawFocusRingPrimitive(primitive, canvas, paint, cornerRadius); | 394 drawFocusRingPrimitive(primitive, canvas, paint, cornerRadius); |
| 400 #endif | 395 #endif |
| 401 } | 396 } |
| 402 | 397 |
| 403 template void PLATFORM_EXPORT drawPlatformFocusRing<SkRect>(const SkRect&, SkCan
vas*, SkColor, int width); | 398 template void PLATFORM_EXPORT drawPlatformFocusRing<SkRect>(const SkRect&, SkCan
vas*, SkColor, int width); |
| 404 template void PLATFORM_EXPORT drawPlatformFocusRing<SkPath>(const SkPath&, SkCan
vas*, SkColor, int width); | 399 template void PLATFORM_EXPORT drawPlatformFocusRing<SkPath>(const SkPath&, SkCan
vas*, SkColor, int width); |
| 405 | 400 |
| 406 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |