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

Side by Side Diff: gm/textblobgeometrychange.cpp

Issue 1868553005: alternate textblobgeometrychange fix... just make our own surface if needed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update dm Created 4 years, 8 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 | « no previous file | tools/dm_flags.json » ('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 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 29 matching lines...) Expand all
40 40
41 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10); 41 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10);
42 42
43 SkAutoTUnref<const SkTextBlob> blob(builder.build()); 43 SkAutoTUnref<const SkTextBlob> blob(builder.build());
44 44
45 SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, canvas->imageInf o().profileType()); 45 SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, canvas->imageInf o().profileType());
46 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); 46 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
47 uint32_t allowSRGBInputs = canvas->getProps(&canvasProps) 47 uint32_t allowSRGBInputs = canvas->getProps(&canvasProps)
48 ? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0; 48 ? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0;
49 SkSurfaceProps props(allowSRGBInputs, kUnknown_SkPixelGeometry); 49 SkSurfaceProps props(allowSRGBInputs, kUnknown_SkPixelGeometry);
50 auto surface(canvas->makeSurface(info, &props)); 50 auto surface = canvas->makeSurface(info, &props);
51 if (surface) { 51 if (!surface) {
52 SkCanvas* c = surface->getCanvas(); 52 surface = SkSurface::MakeRaster(info, &props);
53 }
54 SkCanvas* c = surface->getCanvas();
53 55
54 // LCD text on white background 56 // LCD text on white background
55 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHei ght / 2.f); 57 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f);
56 SkPaint rectPaint; 58 SkPaint rectPaint;
57 rectPaint.setColor(0xffffffff); 59 rectPaint.setColor(0xffffffff);
58 canvas->drawRect(rect, rectPaint); 60 canvas->drawRect(rect, rectPaint);
59 canvas->drawTextBlob(blob.get(), 10, 50, paint); 61 canvas->drawTextBlob(blob.get(), 10, 50, paint);
60 62
61 // This should not look garbled since we should disable LCD text in this case 63 // This should not look garbled since we should disable LCD text in this case
62 // (i.e., unknown pixel geometry) 64 // (i.e., unknown pixel geometry)
63 c->clear(0x00ffffff); 65 c->clear(0x00ffffff);
64 c->drawTextBlob(blob.get(), 10, 150, paint); 66 c->drawTextBlob(blob.get(), 10, 150, paint);
65 surface->draw(canvas, 0, 0, nullptr); 67 surface->draw(canvas, 0, 0, nullptr);
66 } else {
67 const char* text = "This test requires a surface";
68 size_t len = strlen(text);
69 SkPaint paint;
70 canvas->drawText(text, len, 10, 100, paint);
71 }
72 } 68 }
73 69
74 private: 70 private:
75 static const int kWidth = 200; 71 static const int kWidth = 200;
76 static const int kHeight = 200; 72 static const int kHeight = 200;
77 73
78 typedef GM INHERITED; 74 typedef GM INHERITED;
79 }; 75 };
80 76
81 ////////////////////////////////////////////////////////////////////////////// 77 //////////////////////////////////////////////////////////////////////////////
82 78
83 DEF_GM(return new TextBlobGeometryChange;) 79 DEF_GM(return new TextBlobGeometryChange;)
84 } 80 }
OLDNEW
« no previous file with comments | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698