SkDrawProcs.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2011 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 SkDrawProcs_DEFINED
  8. #define SkDrawProcs_DEFINED
  9. #include "src/core/SkDraw.h"
  10. #include "src/core/SkGlyph.h"
  11. bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
  12. SkScalar* coverage);
  13. /**
  14. * If the current paint is set to stroke and the stroke-width when applied to
  15. * the matrix is <= 1.0, then this returns true, and sets coverage (simulating
  16. * a stroke by drawing a hairline with partial coverage). If any of these
  17. * conditions are false, then this returns false and coverage is ignored.
  18. */
  19. inline bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix,
  20. SkScalar* coverage) {
  21. if (SkPaint::kStroke_Style != paint.getStyle()) {
  22. return false;
  23. }
  24. SkScalar strokeWidth = paint.getStrokeWidth();
  25. if (0 == strokeWidth) {
  26. *coverage = SK_Scalar1;
  27. return true;
  28. }
  29. if (!paint.isAntiAlias()) {
  30. return false;
  31. }
  32. return SkDrawTreatAAStrokeAsHairline(strokeWidth, matrix, coverage);
  33. }
  34. #endif