2013-01-02 20:19:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkMatrixUtils_DEFINED
|
|
|
|
#define SkMatrixUtils_DEFINED
|
|
|
|
|
2017-02-07 19:09:38 +00:00
|
|
|
#include "SkPoint.h"
|
2016-01-07 18:34:46 +00:00
|
|
|
#include "SkSize.h"
|
2013-01-02 20:19:45 +00:00
|
|
|
|
2016-01-07 18:34:46 +00:00
|
|
|
class SkMatrix;
|
|
|
|
class SkPaint;
|
2013-01-02 20:19:45 +00:00
|
|
|
|
|
|
|
/**
|
2016-01-07 18:34:46 +00:00
|
|
|
* Given a matrix, size and paint, return true if the computed dst-rect would
|
2013-01-02 20:19:45 +00:00
|
|
|
* 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).
|
|
|
|
*
|
2016-01-07 18:34:46 +00:00
|
|
|
* The src-rect is defined to be { 0, 0, size.width(), size.height() }
|
2013-01-03 15:22:40 +00:00
|
|
|
*/
|
2016-01-07 18:34:46 +00:00
|
|
|
bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkPaint& paint);
|
2013-01-02 20:19:45 +00:00
|
|
|
|
2013-09-03 19:08:14 +00:00
|
|
|
/** 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,
|
2013-09-04 07:01:39 +00:00
|
|
|
followed by another rotation. If there is a reflection, one of the scale
|
2013-09-03 19:08:14 +00:00
|
|
|
factors will be negative.
|
|
|
|
Returns true if successful. Returns false if the matrix is degenerate.
|
2013-07-24 18:08:08 +00:00
|
|
|
*/
|
|
|
|
bool SkDecomposeUpper2x2(const SkMatrix& matrix,
|
2013-09-03 19:08:14 +00:00
|
|
|
SkPoint* rotation1,
|
|
|
|
SkPoint* scale,
|
|
|
|
SkPoint* rotation2);
|
2013-07-24 18:08:08 +00:00
|
|
|
|
2013-01-02 20:19:45 +00:00
|
|
|
#endif
|