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

Unified Diff: gm/textblobgeometrychange.cpp

Issue 1135813007: fix for cached textblobs look garbled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | src/gpu/GrAtlasTextContext.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/textblobgeometrychange.cpp
diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eecad892fe027699561396b679de6c7a040a534b
--- /dev/null
+++ b/gm/textblobgeometrychange.cpp
@@ -0,0 +1,87 @@
+/*
robertphillips 2015/05/11 18:34:41 timewarp
joshualitt 2015/05/11 19:07:47 Acknowledged.
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+
+#include "Resources.h"
+#include "SkCanvas.h"
robertphillips 2015/05/11 18:34:41 Do we need gradient shader ?
joshualitt 2015/05/11 19:07:47 Acknowledged.
+#include "SkGradientShader.h"
+#include "SkStream.h"
+#include "SkSurface.h"
+#include "SkTextBlob.h"
+#include "SkTypeface.h"
+
+namespace skiagm {
robertphillips 2015/05/11 18:34:41 // informative comment ? // link to Chrome bug ?
joshualitt 2015/05/11 19:07:47 Acknowledged.
+class TextBlobGeometryChange : public GM {
+public:
+ TextBlobGeometryChange() { }
+
+protected:
robertphillips 2015/05/11 18:34:41 rm this ?
joshualitt 2015/05/11 19:07:47 Acknowledged.
+ void onOnceBeforeDraw() override {
+ }
+
+ SkString onShortName() override {
+ return SkString("textblobgeometrychange");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(kWidth, kHeight);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ SkPaint paint;
+
+ canvas->clear(0x00ffffff);
bsalomon 2015/05/11 18:33:13 Do we really want the bad looking LCD text on tran
joshualitt 2015/05/11 19:07:47 Acknowledged.
+
robertphillips 2015/05/11 18:34:41 Maybe a build_lcd_blob helper ?
joshualitt 2015/05/11 19:07:47 Acknowledged.
+ const char text[] = "Hamburgefons";
+ SkTDArray<uint16_t> glyphs;
+ size_t len = strlen(text);
+ glyphs.append(paint.textToGlyphs(text, len, NULL));
+ paint.textToGlyphs(text, len, glyphs.begin());
+ paint.setTextSize(20);
+ paint.setAntiAlias(true);
+ paint.setLCDRenderText(true);
+
+ SkTextBlobBuilder builder;
+
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
robertphillips 2015/05/11 18:34:41 overlength
joshualitt 2015/05/11 19:07:47 Acknowledged.
+ const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(paint, glyphs.count(), 10, 10, NULL);
bsalomon 2015/05/11 18:33:13 wrap?
joshualitt 2015/05/11 19:07:47 Acknowledged.
+ memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
+
+ SkAutoTUnref<const SkTextBlob> blob(builder.build());
+
+ SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200);
+ SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
+ SkAutoTUnref<SkSurface> surface(canvas->newSurface(info, &props));
+ SkCanvas* c = surface->getCanvas();
+
+ // LCD text on white background
+ SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight / 2);
+ SkPaint rectPaint;
+ rectPaint.setColor(0xffffffff);
+ canvas->drawRect(rect, rectPaint);
+ canvas->drawTextBlob(blob.get(), 10, 50, paint);
+
+ // This should not look garbled
+ rect = SkRect::MakeLTRB(0, kHeight / 2, kWidth, kHeight);
+ rectPaint.setColor(0x00ffffff);
+ c->drawRect(rect, rectPaint);
+ c->drawTextBlob(blob.get(), 10, 150, paint);
+ surface->draw(canvas, 0, 0, nullptr);
+ }
+
+private:
+ static const int kWidth = 200;
+ static const int kHeight = 200;
+
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_GM( return SkNEW(TextBlobGeometryChange); )
+}
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | src/gpu/GrAtlasTextContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698