diff options
author | reed <reed@google.com> | 2016-01-07 09:15:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-07 09:15:20 -0800 |
commit | 5423ee17ed5a1becd0aeaa89d8faaaa5e2696cbb (patch) | |
tree | bacf1b85ad57770aca87a5b11876a1f1d7b49c58 /src/core/SkMatrixUtils.h | |
parent | 0575cb2def2f4dfdad04e0674d0f8eb8e7c24cec (diff) |
Revert of SkTreatAsSprite should take AA into account (patchset #5 id:80001 of https://codereview.chromium.org/1566943002/ )
Reason for revert:
Need to use SkLeftShift since the arg could be negative
Original issue's description:
> SkTreatAsSprite should take AA into account
>
> Currently we always call SkTreatAsSprite with 0 subpixel bits, which means
> subpixel translations are ignored. This is incorrect for the anti-aliased
> case (drawSprite always pixel-snaps, so we lose edge AA).
>
> The CL updates SkTreatAsSprite to take an SkPaint argument and use 8 subpixel
> bits when AA is requested.
>
> Also remove unused SkTreatAsSpriteFilter.
>
> BUG=skia:4761
> R=reed@google.com
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1566943002
>
> Committed: https://skia.googlesource.com/skia/+/983dc2541a729609037a05eba731b3eb9788c517
TBR=fmalita@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4761
Review URL: https://codereview.chromium.org/1569873003
Diffstat (limited to 'src/core/SkMatrixUtils.h')
-rw-r--r-- | src/core/SkMatrixUtils.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/core/SkMatrixUtils.h b/src/core/SkMatrixUtils.h index 0e01fbe953..d1b6658d07 100644 --- a/src/core/SkMatrixUtils.h +++ b/src/core/SkMatrixUtils.h @@ -8,20 +8,37 @@ #ifndef SkMatrixUtils_DEFINED #define SkMatrixUtils_DEFINED -#include "SkSize.h" +#include "SkMatrix.h" -class SkMatrix; -class SkPaint; +/** + * Number of subpixel bits used in skia's bilerp. + * See SkBitmapProcState_procs.h and SkBitmapProcState_filter.h + */ +#define kSkSubPixelBitsForBilerp 4 /** - * Given a matrix, size and paint, return true if the computed dst-rect would + * Given a matrix and width/height, return true if the computed dst-rect would * align such that there is a 1-to-1 coorspondence between src and dst pixels. * This can be called by drawing code to see if drawBitmap can be turned into * drawSprite (which is faster). * - * The src-rect is defined to be { 0, 0, size.width(), size.height() } + * The src-rect is defined to be { 0, 0, width, height } + * + * The "closeness" test is based on the subpixelBits parameter. Pass 0 for + * round-to-nearest behavior (e.g. nearest neighbor sampling). Pass the number + * of subpixel-bits to simulate filtering. + */ +bool SkTreatAsSprite(const SkMatrix&, int width, int height, + unsigned subpixelBits); + +/** + * Calls SkTreatAsSprite() with default subpixelBits value to match Skia's + * filter-bitmap implementation (i.e. kSkSubPixelBitsForBilerp). */ -bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkPaint& paint); +static inline bool SkTreatAsSpriteFilter(const SkMatrix& matrix, + int width, int height) { + return SkTreatAsSprite(matrix, width, height, kSkSubPixelBitsForBilerp); +} /** Decomposes the upper-left 2x2 of the matrix into a rotation (represented by the cosine and sine of the rotation angle), followed by a non-uniform scale, |