skia2/tests/TextureStripAtlasManagerTest.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

72 lines
2.5 KiB
C++

/*
* 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 "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkSurface.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkTableColorFilter.h"
#include "tests/Test.h"
#include "tools/Resources.h"
// 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,
SkTileMode::kClamp));
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();
}