Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: gm/textblobuseaftergpufree.cpp

Issue 2335493005: Use sk_sp text blob APIs (Closed)
Patch Set: SK_SUPPORT_LEGACY_TEXTBLOB_BUILDER Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/textblobtransforms.cpp ('k') | gm/texteffects.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BD-style license that can be 4 * Use of this source code is governed by a BD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 29 matching lines...) Expand all
40 40
41 SkPaint paint; 41 SkPaint paint;
42 sk_tool_utils::set_portable_typeface(&paint); 42 sk_tool_utils::set_portable_typeface(&paint);
43 paint.setAntiAlias(true); 43 paint.setAntiAlias(true);
44 paint.setTextSize(20); 44 paint.setTextSize(20);
45 45
46 SkTextBlobBuilder builder; 46 SkTextBlobBuilder builder;
47 47
48 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10); 48 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10);
49 49
50 SkAutoTUnref<const SkTextBlob> blob(builder.build()); 50 sk_sp<SkTextBlob> blob(builder.make());
51 51
52 // draw textblob 52 // draw textblob
53 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f); 53 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f);
54 SkPaint rectPaint; 54 SkPaint rectPaint;
55 rectPaint.setColor(0xffffffff); 55 rectPaint.setColor(0xffffffff);
56 canvas->drawRect(rect, rectPaint); 56 canvas->drawRect(rect, rectPaint);
57 canvas->drawTextBlob(blob.get(), 10, 50, paint); 57 canvas->drawTextBlob(blob, 10, 50, paint);
58 58
59 // This text should look fine 59 // This text should look fine
60 canvas->getGrContext()->freeGpuResources(); 60 canvas->getGrContext()->freeGpuResources();
61 canvas->drawTextBlob(blob.get(), 10, 150, paint); 61 canvas->drawTextBlob(blob, 10, 150, paint);
62 } 62 }
63 63
64 private: 64 private:
65 static constexpr int kWidth = 200; 65 static constexpr int kWidth = 200;
66 static constexpr int kHeight = 200; 66 static constexpr int kHeight = 200;
67 67
68 typedef GM INHERITED; 68 typedef GM INHERITED;
69 }; 69 };
70 70
71 ////////////////////////////////////////////////////////////////////////////// 71 //////////////////////////////////////////////////////////////////////////////
72 72
73 DEF_GM(return new TextBlobUseAfterGpuFree;) 73 DEF_GM(return new TextBlobUseAfterGpuFree;)
74 } 74 }
75 #endif 75 #endif
OLDNEW
« no previous file with comments | « gm/textblobtransforms.cpp ('k') | gm/texteffects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698