Request.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  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. #ifndef Request_DEFINED
  8. #define Request_DEFINED
  9. #include "include/core/SkTypes.h"
  10. #include "tools/gpu/GrContextFactory.h"
  11. #include "include/core/SkPicture.h"
  12. #include "include/core/SkStream.h"
  13. #include "include/core/SkSurface.h"
  14. #include "tools/debugger/DebugCanvas.h"
  15. #include "tools/UrlDataManager.h"
  16. namespace sk_gpu_test {
  17. class GrContextFactory;
  18. }
  19. struct MHD_Connection;
  20. struct MHD_PostProcessor;
  21. struct UploadContext {
  22. SkDynamicMemoryWStream fStream;
  23. MHD_PostProcessor* fPostProcessor;
  24. MHD_Connection* connection;
  25. };
  26. struct Request {
  27. Request(SkString rootUrl);
  28. ~Request();
  29. // draws to canvas operation N, highlighting the Mth GrOp. m = -1 means no highlight.
  30. sk_sp<SkData> drawToPng(int n, int m = -1);
  31. sk_sp<SkData> writeOutSkp();
  32. SkCanvas* getCanvas();
  33. bool enableGPU(bool enable);
  34. bool setOverdraw(bool enable);
  35. bool setColorMode(int mode);
  36. bool hasPicture() const { return SkToBool(fPicture.get()); }
  37. int getLastOp() const { return fDebugCanvas->getSize() - 1; }
  38. bool initPictureFromStream(SkStream*);
  39. // Returns the json list of ops as an SkData
  40. sk_sp<SkData> getJsonOps(int n);
  41. // Returns a json list of ops as an SkData
  42. sk_sp<SkData> getJsonOpList(int n);
  43. // Returns json with the viewMatrix and clipRect
  44. sk_sp<SkData> getJsonInfo(int n);
  45. // returns the color of the pixel at (x,y) in the canvas
  46. SkColor getPixel(int x, int y);
  47. UploadContext* fUploadContext;
  48. std::unique_ptr<DebugCanvas> fDebugCanvas;
  49. UrlDataManager fUrlDataManager;
  50. private:
  51. sk_sp<SkData> writeCanvasToPng(SkCanvas* canvas);
  52. SkSurface* createCPUSurface();
  53. SkSurface* createGPUSurface();
  54. SkIRect getBounds();
  55. GrContext* getContext();
  56. sk_sp<SkPicture> fPicture;
  57. sk_gpu_test::GrContextFactory* fContextFactory;
  58. sk_sp<SkSurface> fSurface;
  59. bool fGPUEnabled;
  60. bool fOverdraw;
  61. int fColorMode;
  62. };
  63. #endif