| OLD | NEW |
| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 SkMatrix localMatrix; | 232 SkMatrix localMatrix; |
| 233 // We also need to translate it such that the origin of the pattern is the | 233 // We also need to translate it such that the origin of the pattern is the |
| 234 // origin of the destination rect, which is what WebKit expects. Skia uses | 234 // origin of the destination rect, which is what WebKit expects. Skia uses |
| 235 // the coordinate system origin as the base for the pattern. If WebKit wants | 235 // the coordinate system origin as the base for the pattern. If WebKit wants |
| 236 // a shifted image, it will shift it from there using the localMatrix. | 236 // a shifted image, it will shift it from there using the localMatrix. |
| 237 const float adjustedX = phase.x() + normSrcRect.x() * scale.width(); | 237 const float adjustedX = phase.x() + normSrcRect.x() * scale.width(); |
| 238 const float adjustedY = phase.y() + normSrcRect.y() * scale.height(); | 238 const float adjustedY = phase.y() + normSrcRect.y() * scale.height(); |
| 239 localMatrix.setTranslate(SkFloatToScalar(adjustedX), SkFloatToScalar(adjuste
dY)); | 239 localMatrix.setTranslate(SkFloatToScalar(adjustedX), SkFloatToScalar(adjuste
dY)); |
| 240 | 240 |
| 241 RefPtr<SkShader> shader; | 241 RefPtr<SkShader> shader; |
| 242 SkPaint::FilterLevel filterLevel = static_cast<SkPaint::FilterLevel>(resampl
ing); | 242 SkFilterQuality filterLevel = static_cast<SkFilterQuality>(resampling); |
| 243 | 243 |
| 244 // Bicubic filter is only applied to defer-decoded images, see | 244 // Bicubic filter is only applied to defer-decoded images, see |
| 245 // NativeImageSkia::draw for details. | 245 // NativeImageSkia::draw for details. |
| 246 if (resampling == InterpolationHigh && !isLazyDecoded) { | 246 if (resampling == InterpolationHigh && !isLazyDecoded) { |
| 247 // Do nice resampling. | 247 // Do nice resampling. |
| 248 filterLevel = SkPaint::kNone_FilterLevel; | 248 filterLevel = kNone_SkFilterQuality; |
| 249 float scaleX = destBitmapWidth / normSrcRect.width(); | 249 float scaleX = destBitmapWidth / normSrcRect.width(); |
| 250 float scaleY = destBitmapHeight / normSrcRect.height(); | 250 float scaleY = destBitmapHeight / normSrcRect.height(); |
| 251 SkRect scaledSrcRect; | 251 SkRect scaledSrcRect; |
| 252 | 252 |
| 253 // Since we are resizing the bitmap, we need to remove the scale | 253 // Since we are resizing the bitmap, we need to remove the scale |
| 254 // applied to the pixels in the bitmap shader. This means we need | 254 // applied to the pixels in the bitmap shader. This means we need |
| 255 // CTM * localMatrix to have identity scale. Since we | 255 // CTM * localMatrix to have identity scale. Since we |
| 256 // can't modify CTM (or the rectangle will be drawn in the wrong | 256 // can't modify CTM (or the rectangle will be drawn in the wrong |
| 257 // place), we must set localMatrix's scale to the inverse of | 257 // place), we must set localMatrix's scale to the inverse of |
| 258 // CTM scale. | 258 // CTM scale. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 284 shader = adoptRef(SkShader::CreateBitmapShader( | 284 shader = adoptRef(SkShader::CreateBitmapShader( |
| 285 createBitmapWithSpace(srcSubset, repeatSpacing.width() * ctmScal
eX, repeatSpacing.height() * ctmScaleY), | 285 createBitmapWithSpace(srcSubset, repeatSpacing.width() * ctmScal
eX, repeatSpacing.height() * ctmScaleY), |
| 286 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMa
trix)); | 286 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMa
trix)); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 SkPaint paint; | 290 SkPaint paint; |
| 291 paint.setShader(shader.get()); | 291 paint.setShader(shader.get()); |
| 292 paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode
)); | 292 paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode
)); |
| 293 paint.setColorFilter(context->colorFilter()); | 293 paint.setColorFilter(context->colorFilter()); |
| 294 paint.setFilterLevel(filterLevel); | 294 paint.setFilterQuality(filterLevel); |
| 295 context->drawRect(destRect, paint); | 295 context->drawRect(destRect, paint); |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool NativeImageSkia::shouldCacheResampling(const SkISize& scaledImageSize, cons
t SkIRect& scaledImageSubset) const | 298 bool NativeImageSkia::shouldCacheResampling(const SkISize& scaledImageSize, cons
t SkIRect& scaledImageSubset) const |
| 299 { | 299 { |
| 300 // Check whether the requested dimensions match previous request. | 300 // Check whether the requested dimensions match previous request. |
| 301 bool matchesPreviousRequest = m_cachedImageInfo.isEqual(scaledImageSize, sca
ledImageSubset); | 301 bool matchesPreviousRequest = m_cachedImageInfo.isEqual(scaledImageSize, sca
ledImageSubset); |
| 302 if (matchesPreviousRequest) | 302 if (matchesPreviousRequest) |
| 303 ++m_resizeRequests; | 303 ++m_resizeRequests; |
| 304 else { | 304 else { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca
ledImageSubset) | 361 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca
ledImageSubset) |
| 362 { | 362 { |
| 363 if (!scaledImageSubset.contains(otherScaledImageSubset)) | 363 if (!scaledImageSubset.contains(otherScaledImageSubset)) |
| 364 return SkIRect::MakeEmpty(); | 364 return SkIRect::MakeEmpty(); |
| 365 SkIRect subsetRect = otherScaledImageSubset; | 365 SkIRect subsetRect = otherScaledImageSubset; |
| 366 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); | 366 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); |
| 367 return subsetRect; | 367 return subsetRect; |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace blink | 370 } // namespace blink |
| OLD | NEW |