fiddle_main.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2015 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 fiddle_main_DEFINED
  8. #define fiddle_main_DEFINED
  9. #ifdef FIDDLE_BUILD_TEST
  10. #include "include/core/SkCanvas.h"
  11. #include "include/core/SkDocument.h"
  12. #include "include/core/SkPictureRecorder.h"
  13. #include "include/core/SkStream.h"
  14. #include "include/core/SkSurface.h"
  15. #include "include/gpu/GrContext.h"
  16. #include "include/gpu/gl/GrGLAssembleInterface.h"
  17. #include "include/gpu/gl/GrGLInterface.h"
  18. #else
  19. #include "skia.h"
  20. #endif
  21. #include <memory>
  22. #include <sstream>
  23. extern GrBackendTexture backEndTexture;
  24. extern GrBackendRenderTarget backEndRenderTarget;
  25. extern GrBackendTexture backEndTextureRenderTarget;
  26. extern SkBitmap source;
  27. extern sk_sp<SkImage> image;
  28. extern double duration; // The total duration of the animation in seconds.
  29. extern double frame; // A value in [0, 1] of where we are in the animation.
  30. namespace sk_gpu_test {
  31. class GLTestContext;
  32. }
  33. struct DrawOptions {
  34. DrawOptions(int w, int h, bool r, bool g, bool p, bool k, bool srgb, bool f16,
  35. bool textOnly, const char* s,
  36. GrMipMapped mipMapping,
  37. int offScreenWidth,
  38. int offScreenHeight,
  39. int offScreenSampleCount,
  40. GrMipMapped offScreenMipMapping)
  41. : size(SkISize::Make(w, h))
  42. , raster(r)
  43. , gpu(g)
  44. , pdf(p)
  45. , skp(k)
  46. , srgb(srgb)
  47. , f16(f16)
  48. , textOnly(textOnly)
  49. , source(s)
  50. , fMipMapping(mipMapping)
  51. , fOffScreenWidth(offScreenWidth)
  52. , fOffScreenHeight(offScreenHeight)
  53. , fOffScreenSampleCount(offScreenSampleCount)
  54. , fOffScreenMipMapping(offScreenMipMapping) {
  55. // F16 mode is only valid for color correct backends.
  56. SkASSERT(srgb || !f16);
  57. }
  58. SkISize size;
  59. bool raster;
  60. bool gpu;
  61. bool pdf;
  62. bool skp;
  63. bool srgb;
  64. bool f16;
  65. bool textOnly;
  66. const char* source;
  67. // This flag is used when a GPU texture resource is created and exposed as a GrBackendTexture.
  68. // In this case the resource is created with extra room to accomodate mipmaps.
  69. // TODO: The SkImage::makeTextureImage API would need to be widened to allow this to be true
  70. // for the non-backend gpu SkImages.
  71. GrMipMapped fMipMapping;
  72. // Parameters for an GPU offscreen resource exposed as a GrBackendRenderTarget
  73. int fOffScreenWidth;
  74. int fOffScreenHeight;
  75. int fOffScreenSampleCount;
  76. // TODO: should we also expose stencilBits here? How about the config?
  77. GrMipMapped fOffScreenMipMapping; // only applicable if the offscreen is also textureable
  78. };
  79. extern DrawOptions GetDrawOptions();
  80. extern void SkDebugf(const char * format, ...);
  81. extern void draw(SkCanvas*);
  82. // There are different implementations of create_grcontext() for EGL, Mesa,
  83. // and a fallback to a null context.
  84. extern sk_sp<GrContext> create_grcontext(std::ostringstream& driverinfo,
  85. std::unique_ptr<sk_gpu_test::GLTestContext>* glContext);
  86. #endif // fiddle_main_DEFINED