Home | History | Annotate | Download | only in gm
      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 
      8 #include "gm.h"
      9 #include "sk_tool_utils.h"
     10 
     11 #include "SkBlurMask.h"
     12 #include "SkBlurMaskFilter.h"
     13 #include "SkCanvas.h"
     14 #include "SkTextBlob.h"
     15 
     16 // This test ensures that glyphs whose point size is less than the SkGlyphCache's maxmium, but
     17 // who have a large blur, are still handled correctly
     18 DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
     19         const char text[] = "Hamburgefons";
     20 
     21         SkPaint paint;
     22         sk_tool_utils::set_portable_typeface(&paint);
     23         paint.setTextSize(256);
     24         paint.setAntiAlias(true);
     25 
     26         // setup up maskfilter
     27         const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
     28 
     29         SkPaint blurPaint(paint);
     30         blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma));
     31 
     32         SkTextBlobBuilder builder;
     33 
     34         sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
     35 
     36         sk_sp<SkTextBlob> blob(builder.make());
     37         canvas->drawTextBlob(blob, 10, 200, blurPaint);
     38         canvas->drawTextBlob(blob, 10, 200, paint);
     39 
     40         size_t len = strlen(text);
     41         canvas->drawText(text, len, 10, 500, blurPaint);
     42         canvas->drawText(text, len, 10, 500, paint);
     43 }
     44