blob: 02435d16142e9e67266578fd609006202a28d05e [file] [log] [blame]
joshualitt24dd6872016-02-25 08:37:54 -08001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef Request_DEFINED
9#define Request_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkTypes.h"
mtkleinecbc5262016-09-22 11:51:24 -070012
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "tools/gpu/GrContextFactory.h"
joshualitt24dd6872016-02-25 08:37:54 -080014
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "include/core/SkPicture.h"
16#include "include/core/SkStream.h"
17#include "include/core/SkSurface.h"
18#include "tools/debugger/DebugCanvas.h"
joshualitt24dd6872016-02-25 08:37:54 -080019
Mike Kleinc0bd9f92019-04-23 12:05:21 -050020#include "tools/UrlDataManager.h"
joshualitt24dd6872016-02-25 08:37:54 -080021
bsalomon3724e572016-03-30 18:56:19 -070022namespace sk_gpu_test {
joshualitt40836102016-03-11 11:45:53 -080023class GrContextFactory;
bsalomon3724e572016-03-30 18:56:19 -070024}
joshualitt24dd6872016-02-25 08:37:54 -080025struct MHD_Connection;
26struct MHD_PostProcessor;
27
28struct UploadContext {
29 SkDynamicMemoryWStream fStream;
30 MHD_PostProcessor* fPostProcessor;
31 MHD_Connection* connection;
32};
33
34struct Request {
joshualitt40836102016-03-11 11:45:53 -080035 Request(SkString rootUrl);
36 ~Request();
joshualitt24dd6872016-02-25 08:37:54 -080037
Brian Salomon144a5c52016-12-20 16:48:59 -050038 // draws to canvas operation N, highlighting the Mth GrOp. m = -1 means no highlight.
bungeman38d909e2016-08-02 14:40:46 -070039 sk_sp<SkData> drawToPng(int n, int m = -1);
40 sk_sp<SkData> writeOutSkp();
joshualitt4dcbe432016-02-25 10:50:28 -080041 SkCanvas* getCanvas();
joshualittee5348b2016-02-26 08:36:25 -080042 bool enableGPU(bool enable);
Ben Wagnerc03e1c52016-10-17 15:20:02 -040043 bool setOverdraw(bool enable);
brianosman78312952016-04-19 10:16:53 -070044 bool setColorMode(int mode);
joshualitt1e5884b2016-02-26 08:22:49 -080045 bool hasPicture() const { return SkToBool(fPicture.get()); }
46 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
47
joshualitt6bc96792016-02-29 05:35:04 -080048 bool initPictureFromStream(SkStream*);
49
joshualitt1e5884b2016-02-26 08:22:49 -080050 // Returns the json list of ops as an SkData
Nathaniel Nifonga072b7b2019-12-13 13:51:14 -050051 sk_sp<SkData> getJsonOps();
joshualitt1e5884b2016-02-26 08:22:49 -080052
Brian Salomon144a5c52016-12-20 16:48:59 -050053 // Returns a json list of ops as an SkData
Nathaniel Nifonga072b7b2019-12-13 13:51:14 -050054 sk_sp<SkData> getJsonOpsTask();
joshualitt4dcbe432016-02-25 10:50:28 -080055
Nathaniel Nifonga072b7b2019-12-13 13:51:14 -050056 // Returns json with the viewMatrix and clipRect at the given command
bungeman38d909e2016-08-02 14:40:46 -070057 sk_sp<SkData> getJsonInfo(int n);
joshualittee5348b2016-02-26 08:36:25 -080058
joshualitte0449cf2016-03-09 10:07:02 -080059 // returns the color of the pixel at (x,y) in the canvas
60 SkColor getPixel(int x, int y);
joshualitt4dcbe432016-02-25 10:50:28 -080061
joshualitt24dd6872016-02-25 08:37:54 -080062 UploadContext* fUploadContext;
Mike Klein8f4e2242019-03-20 11:59:00 -050063 std::unique_ptr<DebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080064 UrlDataManager fUrlDataManager;
halcanary9d524f22016-03-29 09:03:52 -070065
joshualittee5348b2016-02-26 08:36:25 -080066private:
bungeman38d909e2016-08-02 14:40:46 -070067 sk_sp<SkData> writeCanvasToPng(SkCanvas* canvas);
joshualittee5348b2016-02-26 08:36:25 -080068 SkSurface* createCPUSurface();
69 SkSurface* createGPUSurface();
joshualittae47aee2016-03-10 13:29:36 -080070 SkIRect getBounds();
71 GrContext* getContext();
halcanary9d524f22016-03-29 09:03:52 -070072
reedca2622b2016-03-18 07:25:55 -070073 sk_sp<SkPicture> fPicture;
bsalomon3724e572016-03-30 18:56:19 -070074 sk_gpu_test::GrContextFactory* fContextFactory;
Hal Canary1b612a82016-11-03 16:26:13 -040075 sk_sp<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080076 bool fGPUEnabled;
Ben Wagnerc03e1c52016-10-17 15:20:02 -040077 bool fOverdraw;
brianosman78312952016-04-19 10:16:53 -070078 int fColorMode;
joshualitt24dd6872016-02-25 08:37:54 -080079};
80
81#endif