largeglyphblur.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "gm/gm.h"
  8. #include "include/core/SkBlurTypes.h"
  9. #include "include/core/SkCanvas.h"
  10. #include "include/core/SkFont.h"
  11. #include "include/core/SkFontTypes.h"
  12. #include "include/core/SkMaskFilter.h"
  13. #include "include/core/SkPaint.h"
  14. #include "include/core/SkScalar.h"
  15. #include "include/core/SkTextBlob.h"
  16. #include "include/core/SkTypeface.h"
  17. #include "src/core/SkBlurMask.h"
  18. #include "tools/ToolUtils.h"
  19. #include <string.h>
  20. // This test ensures that glyphs whose point size is less than the SkStrike's maxmium, but
  21. // who have a large blur, are still handled correctly
  22. DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
  23. const char text[] = "Hamburgefons";
  24. SkFont font(ToolUtils::create_portable_typeface(), 256);
  25. auto blob = SkTextBlob::MakeFromText(text, strlen(text), font);
  26. // setup up maskfilter
  27. const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
  28. SkPaint blurPaint;
  29. blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma));
  30. canvas->drawTextBlob(blob, 10, 200, blurPaint);
  31. canvas->drawTextBlob(blob, 10, 200, SkPaint());
  32. size_t len = strlen(text);
  33. canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, blurPaint);
  34. canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, SkPaint());
  35. }