SkMatrixUtils.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. #ifndef SkMatrixUtils_DEFINED
  8. #define SkMatrixUtils_DEFINED
  9. #include "include/core/SkPoint.h"
  10. #include "include/core/SkSize.h"
  11. class SkMatrix;
  12. class SkPaint;
  13. /**
  14. * Given a matrix, size and paint, return true if the computed dst-rect would
  15. * align such that there is a 1-to-1 coorspondence between src and dst pixels.
  16. * This can be called by drawing code to see if drawBitmap can be turned into
  17. * drawSprite (which is faster).
  18. *
  19. * The src-rect is defined to be { 0, 0, size.width(), size.height() }
  20. */
  21. bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkPaint& paint);
  22. /** Decomposes the upper-left 2x2 of the matrix into a rotation (represented by
  23. the cosine and sine of the rotation angle), followed by a non-uniform scale,
  24. followed by another rotation. If there is a reflection, one of the scale
  25. factors will be negative.
  26. Returns true if successful. Returns false if the matrix is degenerate.
  27. */
  28. bool SkDecomposeUpper2x2(const SkMatrix& matrix,
  29. SkPoint* rotation1,
  30. SkPoint* scale,
  31. SkPoint* rotation2);
  32. #endif