1 /*
2  * Copyright 2013 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkMatrixUtils_DEFINED
9 #define SkMatrixUtils_DEFINED
10 
11 #include "SkSize.h"
12 
13 class SkMatrix;
14 class SkPaint;
15 
16 /**
17  *  Given a matrix, size and paint, return true if the computed dst-rect would
18  *  align such that there is a 1-to-1 coorspondence between src and dst pixels.
19  *  This can be called by drawing code to see if drawBitmap can be turned into
20  *  drawSprite (which is faster).
21  *
22  *  The src-rect is defined to be { 0, 0, size.width(), size.height() }
23  */
24 bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkPaint& paint);
25 
26 /** Decomposes the upper-left 2x2 of the matrix into a rotation (represented by
27     the cosine and sine of the rotation angle), followed by a non-uniform scale,
28     followed by another rotation. If there is a reflection, one of the scale
29     factors will be negative.
30     Returns true if successful. Returns false if the matrix is degenerate.
31     */
32 bool SkDecomposeUpper2x2(const SkMatrix& matrix,
33                          SkPoint* rotation1,
34                          SkPoint* scale,
35                          SkPoint* rotation2);
36 
37 #endif
38