diff options
author | Greg Daniel <egdaniel@google.com> | 2017-12-18 15:50:34 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-18 21:50:26 +0000 |
commit | f226e66d75374e370f3ae2c6895bc689670e9e18 (patch) | |
tree | b1e38311a08f7294f366fe3e89c4ba231f3be600 /gm | |
parent | de71572f650005e36d4fc2fe95fb5677a25ae4f6 (diff) |
Revert "Transform vertices for distance field glyphs on CPU."
This reverts commit 0215e39d7e415d0530231df6ad20d5f215c72152.
Reason for revert: break intel 540 and HD2000 intel release bots on gltestthreading gm dftext_blob_pers
Original change's description:
> Transform vertices for distance field glyphs on CPU.
>
> This allows batching of DF draws with different view matrices.
>
> For perspective matrices this means the transformed position vertex
> attribute must have w values. Currently, non-perspective DF draws still
> use 2 component positions, though this could be changed in the future.
> Consequently, perspective draws can batch with other perspective draws
> but not non-perspective draws.
>
> Adds a GM to test batching and reusing the same blobs with both perspective
> and non-perspective matrices.
>
> Change-Id: I0e42c5449ebf3a5a54025dbcdec824d904d5bd9e
> Reviewed-on: https://skia-review.googlesource.com/79900
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
TBR=jvanverth@google.com,bsalomon@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: Idc658d9263976d5b5e00a5026c5d6d3c8f4bdc2d
Reviewed-on: https://skia-review.googlesource.com/86560
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/dftext_blob_persp.cpp | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/gm/dftext_blob_persp.cpp b/gm/dftext_blob_persp.cpp deleted file mode 100644 index cfa681d984..0000000000 --- a/gm/dftext_blob_persp.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "gm.h" -#include "Resources.h" -#include "SkCanvas.h" -#include "SkSurface.h" -#include "SkTextBlob.h" -#include "SkTypeface.h" -#include "sk_tool_utils.h" - -/** - * This GM tests reusing the same text blobs with distance fields rendering using various - * combinations of perspective and non-perspetive matrices, scissor clips, and different x,y params - * passed to the draw. - */ -class DFTextBlobPerspGM : public skiagm::GM { -public: - DFTextBlobPerspGM() { this->setBGColor(0xFFFFFFFF); } - -protected: - SkString onShortName() override { - SkString name("dftext_blob_persp"); - name.append(sk_tool_utils::platform_font_manager()); - return name; - } - - SkISize onISize() override { return SkISize::Make(900, 350); } - - void onOnceBeforeDraw() override { - for (int i = 0; i < 3; ++i) { - SkPaint paint; - paint.setTextSize(32); - paint.setAntiAlias(i > 0); - paint.setLCDRenderText(i > 1); - paint.setSubpixelText(true); - SkTextBlobBuilder builder; - sk_tool_utils::add_to_text_blob(&builder, "SkiaText", paint, 0, 0); - fBlobs.emplace_back(builder.make()); - } - } - - virtual void onDraw(SkCanvas* inputCanvas) override { - // set up offscreen rendering with distance field text -#if SK_SUPPORT_GPU - GrContext* ctx = inputCanvas->getGrContext(); - SkISize size = this->onISize(); - if (!inputCanvas->getBaseLayerSize().isEmpty()) { - size = inputCanvas->getBaseLayerSize(); - } - SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType, - inputCanvas->imageInfo().refColorSpace()); - SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag, - SkSurfaceProps::kLegacyFontHost_InitType); - auto surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props); - SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas; - // init our new canvas with the old canvas's matrix - canvas->setMatrix(inputCanvas->getTotalMatrix()); -#else - SkCanvas* canvas = inputCanvas; -#endif - SkScalar x = 0, y = 0; - SkScalar maxH = 0; - for (auto twm : {TranslateWithMatrix::kNo, TranslateWithMatrix::kYes}) { - for (auto pm : {PerspMode::kNone, PerspMode::kX, PerspMode::kY, PerspMode::kXY}) { - for (auto& blob : fBlobs) { - for (bool clip : {false, true}) { - canvas->save(); - SkScalar w = blob->bounds().width(); - SkScalar h = blob->bounds().height(); - if (clip) { - auto rect = - SkRect::MakeXYWH(x + 5, y + 5, w * 3.f / 4.f, h * 3.f / 4.f); - canvas->clipRect(rect, false); - } - this->drawBlob(canvas, blob.get(), SK_ColorBLACK, x, y + h, pm, twm); - x += w + 20.f; - maxH = SkTMax(h, maxH); - canvas->restore(); - } - } - x = 0; - y += maxH + 20.f; - maxH = 0; - } - } -#if SK_SUPPORT_GPU - // render offscreen buffer - if (surface) { - SkAutoCanvasRestore acr(inputCanvas, true); - // since we prepended this matrix already, we blit using identity - inputCanvas->resetMatrix(); - inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, nullptr); - } -#endif - } - -private: - enum class PerspMode { kNone, kX, kY, kXY }; - - enum class TranslateWithMatrix : bool { kNo, kYes }; - - void drawBlob(SkCanvas* canvas, SkTextBlob* blob, SkColor color, SkScalar x, SkScalar y, - PerspMode perspMode, TranslateWithMatrix translateWithMatrix) { - canvas->save(); - SkMatrix persp = SkMatrix::I(); - switch (perspMode) { - case PerspMode::kNone: - break; - case PerspMode::kX: - persp.setPerspX(0.005f); - break; - case PerspMode::kY: - persp.setPerspY(00.005f); - break; - case PerspMode::kXY: - persp.setPerspX(-0.001f); - persp.setPerspY(-0.0015f); - break; - } - persp = SkMatrix::Concat(persp, SkMatrix::MakeTrans(-x, -y)); - persp = SkMatrix::Concat(SkMatrix::MakeTrans(x, y), persp); - canvas->concat(persp); - if (TranslateWithMatrix::kYes == translateWithMatrix) { - canvas->translate(x, y); - x = 0; - y = 0; - } - SkPaint paint; - paint.setColor(color); - canvas->drawTextBlob(blob, x, y, paint); - canvas->restore(); - } - - SkTArray<sk_sp<SkTextBlob>, true> fBlobs; - typedef skiagm::GM INHERITED; -}; - -DEF_GM(return new DFTextBlobPerspGM;) |