skia2/tools/gpucts/gm_runner.h
Brian Salomon dcfca431e3 Use GrContextFactories that produce a single GrContext in unit tests.
This is to alleviate problems due to the command buffer getting bent out of shape when the current
OpenGL context is switched out from under it (because we ran a test with a native GL context). This,
however is not a full solution. More changes will be required to ensure that after running each
command buffer or native test we bind the null context. This does allow us to take a step in that
direction without breaking anything too badly. Moreover, there is no real benefit to reusing a
GrContextFactory.

Modifies DEF_GPUTEST to take GrContextOptions rather than a factory to use. Tests were already using
their own factories anyway.

In tests that use GrContextFactory the factory instance is moved to the inner loop.

Modifies gpucts and skia_test to not use persistent GrContextFactories.

Change-Id: Ie7a36793545c775f2f30653ead6fec93a3d22717
Reviewed-on: https://skia-review.googlesource.com/71861
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2017-11-15 22:03:07 +00:00

66 lines
1.3 KiB
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef gm_runner_DEFINED
#define gm_runner_DEFINED
#include <memory>
#include <string>
#include <vector>
#include "gm_knowledge.h"
/**
A Skia GM is a single rendering test that can be executed on any Skia backend Canvas.
*/
namespace skiagm {
class GM;
}
namespace sk_gpu_test {
class GrContextFactory;
}
namespace gm_runner {
using GMFactory = skiagm::GM* (*)(void*);
enum class SkiaBackend {
kGL,
kGLES,
kVulkan,
};
bool BackendSupported(SkiaBackend);
/**
@return a list of all Skia GMs in lexicographic order.
*/
std::vector<GMFactory> GetGMFactories();
/**
@return a descriptive name for the GM.
*/
std::string GetGMName(GMFactory);
/**
@return a descriptive name for the backend.
*/
const char* GetBackendName(SkiaBackend);
/**
Execute the given GM on the given Skia backend. Then copy the pixels into the
storage (overwriting existing contents of storage).
@return the rendered image. Return a null ImageData on error.
*/
GMK_ImageData Evaluate(SkiaBackend,
GMFactory,
std::vector<uint32_t>* storage);
} // namespace gm_runner
#endif // gm_runner_DEFINED