diff options
author | Robert Phillips <robertphillips@google.com> | 2018-03-19 10:57:42 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-19 15:36:26 +0000 |
commit | 96b6d537c2466ec760af816cde1fd665d2011fab (patch) | |
tree | 504476d9c0e27a915563a56a841e0432668daafb /tests/TextureStripAtlasManagerTest.cpp | |
parent | f7466bd84acd28594b3f4df47d91211d9508a16e (diff) |
Fix GrTextureStripAtlasManager cleanup order bug
Bug: 820703
Change-Id: I6f1a895ceb213d38361bc03a472cf2a48e4720a5
Reviewed-on: https://skia-review.googlesource.com/115001
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/TextureStripAtlasManagerTest.cpp')
-rw-r--r-- | tests/TextureStripAtlasManagerTest.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/TextureStripAtlasManagerTest.cpp b/tests/TextureStripAtlasManagerTest.cpp new file mode 100644 index 0000000000..d03529f120 --- /dev/null +++ b/tests/TextureStripAtlasManagerTest.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#include "SkCanvas.h" +#include "SkGradientShader.h" +#include "SkPaint.h" +#include "SkSurface.h" +#include "SkTableColorFilter.h" + +#include "Resources.h" +#include "Test.h" + +#if SK_SUPPORT_GPU // These are all GPU-backend specific tests + + +// The gradient shader will use the texture strip atlas if it has too many colors. Make sure +// abandoning the context works. +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureStripAtlasManagerGradientTest, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + + static const SkColor gColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, + SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW, + SK_ColorBLACK }; + static const SkScalar gPos[] = { 0, 0.17f, 0.32f, 0.49f, 0.66f, 0.83f, 1.0f }; + + SkPaint p; + p.setShader(SkGradientShader::MakeTwoPointConical(SkPoint::Make(0, 0), + 1.0f, + SkPoint::Make(10.0f, 20.0f), + 2.0f, + gColors, + gPos, + 7, + SkShader::kClamp_TileMode)); + + SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); + auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); + SkCanvas* canvas = surface->getCanvas(); + + SkRect r = SkRect::MakeXYWH(10, 10, 100, 100); + + canvas->drawRect(r, p); + + context->abandonContext(); +} + +// The table color filter uses the texture strip atlas. Make sure abandoning the context works. +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureStripAtlasManagerColorFilterTest, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + + sk_sp<SkImage> img = GetResourceAsImage("images/mandrill_128.png"); + + + uint8_t identity[256]; + for (int i = 0; i < 256; i++) { + identity[i] = i; + } + + SkPaint p; + p.setColorFilter(SkTableColorFilter::Make(identity)); + + SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); + auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); + SkCanvas* canvas = surface->getCanvas(); + + canvas->drawImage(std::move(img), 0, 0, &p); + + context->abandonContext(); +} + +#endif |