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

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

Issue 641643004: Reapply the non-MathExtras parts of (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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
« no previous file with comments | « Source/platform/geometry/IntRect.cpp ('k') | Source/platform/mac/ThemeMac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // 75 //
76 // scaledSrcRect = srcRect * (approximateScaleX, approximateScaleY) 76 // scaledSrcRect = srcRect * (approximateScaleX, approximateScaleY)
77 // enclosingScaledSrcRect = enclosingIntRect(scaledSrcRect) 77 // enclosingScaledSrcRect = enclosingIntRect(scaledSrcRect)
78 // 78 //
79 // Finally we extract the scaled image fragment using 79 // Finally we extract the scaled image fragment using
80 // (scaledImageSize, enclosingScaledSrcRect). 80 // (scaledImageSize, enclosingScaledSrcRect).
81 // 81 //
82 SkBitmap NativeImageSkia::extractScaledImageFragment(const SkRect& srcRect, floa t scaleX, float scaleY, SkRect* scaledSrcRect) const 82 SkBitmap NativeImageSkia::extractScaledImageFragment(const SkRect& srcRect, floa t scaleX, float scaleY, SkRect* scaledSrcRect) const
83 { 83 {
84 SkISize imageSize = SkISize::Make(bitmap().width(), bitmap().height()); 84 SkISize imageSize = SkISize::Make(bitmap().width(), bitmap().height());
85 SkISize scaledImageSize = SkISize::Make(clampToInteger(roundf(imageSize.widt h() * scaleX)), 85 SkISize scaledImageSize = SkISize::Make(clampTo<int>(roundf(imageSize.width( ) * scaleX)),
86 clampToInteger(roundf(imageSize.height() * scaleY))); 86 clampTo<int>(roundf(imageSize.height() * scaleY)));
87 87
88 SkRect imageRect = SkRect::MakeWH(imageSize.width(), imageSize.height()); 88 SkRect imageRect = SkRect::MakeWH(imageSize.width(), imageSize.height());
89 SkRect scaledImageRect = SkRect::MakeWH(scaledImageSize.width(), scaledImage Size.height()); 89 SkRect scaledImageRect = SkRect::MakeWH(scaledImageSize.width(), scaledImage Size.height());
90 90
91 SkMatrix scaleTransform; 91 SkMatrix scaleTransform;
92 scaleTransform.setRectToRect(imageRect, scaledImageRect, SkMatrix::kFill_Sca leToFit); 92 scaleTransform.setRectToRect(imageRect, scaledImageRect, SkMatrix::kFill_Sca leToFit);
93 scaleTransform.mapRect(scaledSrcRect, srcRect); 93 scaleTransform.mapRect(scaledSrcRect, srcRect);
94 94
95 scaledSrcRect->intersect(scaledImageRect); 95 scaledSrcRect->intersect(scaledImageRect);
96 SkIRect enclosingScaledSrcRect = enclosingIntRect(*scaledSrcRect); 96 SkIRect enclosingScaledSrcRect = enclosingIntRect(*scaledSrcRect);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca ledImageSubset) 369 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca ledImageSubset)
370 { 370 {
371 if (!scaledImageSubset.contains(otherScaledImageSubset)) 371 if (!scaledImageSubset.contains(otherScaledImageSubset))
372 return SkIRect::MakeEmpty(); 372 return SkIRect::MakeEmpty();
373 SkIRect subsetRect = otherScaledImageSubset; 373 SkIRect subsetRect = otherScaledImageSubset;
374 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); 374 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y());
375 return subsetRect; 375 return subsetRect;
376 } 376 }
377 377
378 } // namespace blink 378 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/geometry/IntRect.cpp ('k') | Source/platform/mac/ThemeMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698