Update final set of tools to take GrDirectContext

This updates skiaserve, fm, and the fuzzer

Change-Id: Ia1b447b79723eeab73da11755d28f7ab443d5fbb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300263
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-07-01 16:59:17 -04:00 committed by Skia Commit-Bot
parent b827e97d2b
commit 7b4e43c522
5 changed files with 14 additions and 12 deletions

View File

@ -50,6 +50,7 @@
#include "tools/flags/CommandLineFlags.h"
#ifdef SK_GL
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/gl/GrGLFunctions.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/gl/GrGLGpu.h"
@ -1707,7 +1708,7 @@ DEF_FUZZ(SerializedImageFilter, fuzz) {
#ifdef SK_GL
static void dump_GPU_info(GrContext* context) {
static void dump_GPU_info(GrDirectContext* context) {
const GrGLInterface* gl = static_cast<GrGLGpu*>(context->priv().getGpu())
->glInterface();
const GrGLubyte* output;
@ -1721,7 +1722,7 @@ static void dump_GPU_info(GrContext* context) {
SkDebugf("GL_VERSION %s\n", (const char*) output);
}
static void fuzz_ganesh(Fuzz* fuzz, GrContext* context) {
static void fuzz_ganesh(Fuzz* fuzz, GrDirectContext* context) {
SkASSERT(context);
auto surface = SkSurface::MakeRenderTarget(
context,
@ -1733,7 +1734,7 @@ static void fuzz_ganesh(Fuzz* fuzz, GrContext* context) {
DEF_FUZZ(NativeGLCanvas, fuzz) {
sk_gpu_test::GrContextFactory f;
GrContext* context = f.get(sk_gpu_test::GrContextFactory::kGL_ContextType);
auto context = f.get(sk_gpu_test::GrContextFactory::kGL_ContextType);
if (!context) {
context = f.get(sk_gpu_test::GrContextFactory::kGLES_ContextType);
}

View File

@ -11,6 +11,7 @@
#include "include/core/SkPictureRecorder.h"
#include "include/docs/SkPDFDocument.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkTHash.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkMD5.h"
@ -301,8 +302,7 @@ static sk_sp<SkImage> draw_with_gpu(std::function<bool(SkCanvas*)> draw,
auto overrides = GrContextFactory::ContextOverrides::kNone;
if (!FLAGS_stencils) { overrides |= GrContextFactory::ContextOverrides::kAvoidStencilBuffers; }
GrContext* context = factory->getContextInfo(api, overrides)
.grContext();
auto context = factory->getContextInfo(api, overrides).directContext();
uint32_t flags = FLAGS_dit ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag
: 0;

View File

@ -8,6 +8,7 @@
#include "tools/skiaserve/Request.h"
#include "include/core/SkPictureRecorder.h"
#include "include/gpu/GrDirectContext.h"
#include "src/utils/SkJSONWriter.h"
#include "tools/ToolUtils.h"
@ -92,9 +93,9 @@ sk_sp<SkData> Request::writeOutSkp() {
return recorder.finishRecordingAsPicture()->serialize();
}
GrContext* Request::getContext() {
GrContext* result = fContextFactory->get(GrContextFactory::kGL_ContextType,
GrContextFactory::ContextOverrides::kNone);
GrDirectContext* Request::directContext() {
auto result = fContextFactory->get(GrContextFactory::kGL_ContextType,
GrContextFactory::ContextOverrides::kNone);
if (!result) {
result = fContextFactory->get(GrContextFactory::kGLES_ContextType,
GrContextFactory::ContextOverrides::kNone);
@ -107,7 +108,7 @@ SkIRect Request::getBounds() {
if (fPicture) {
bounds = fPicture->cullRect().roundOut();
if (fGPUEnabled) {
int maxRTSize = this->getContext()->maxRenderTargetSize();
int maxRTSize = this->directContext()->maxRenderTargetSize();
bounds = SkIRect::MakeWH(std::min(bounds.width(), maxRTSize),
std::min(bounds.height(), maxRTSize));
}
@ -149,7 +150,7 @@ SkSurface* Request::createCPUSurface() {
}
SkSurface* Request::createGPUSurface() {
GrContext* context = this->getContext();
auto context = this->directContext();
SkIRect bounds = this->getBounds();
ColorAndProfile cap = ColorModes[fColorMode];
auto colorSpace = kRGBA_F16_SkColorType == cap.fColorType

View File

@ -68,7 +68,7 @@ private:
SkSurface* createCPUSurface();
SkSurface* createGPUSurface();
SkIRect getBounds();
GrContext* getContext();
GrDirectContext* directContext();
sk_sp<SkPicture> fPicture;
sk_gpu_test::GrContextFactory* fContextFactory;

View File

@ -556,7 +556,7 @@ int main(int argc, char** argv) {
sk_gpu_test::GrContextFactory factory(ctxOptions);
sk_gpu_test::ContextInfo ctxInfo =
factory.getContextInfo(config->getContextType(), config->getContextOverrides());
GrDirectContext* ctx = ctxInfo.directContext();
auto ctx = ctxInfo.directContext();
if (!ctx) {
exitf(ExitErr::kUnavailable, "failed to create context for config %s",
config->getTag().c_str());