SkNoDrawCanvas.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 SkNoDrawCanvas_DEFINED
  8. #define SkNoDrawCanvas_DEFINED
  9. #include "include/core/SkCanvas.h"
  10. #include "include/core/SkCanvasVirtualEnforcer.h"
  11. #include "include/core/SkVertices.h"
  12. struct SkIRect;
  13. // SkNoDrawCanvas is a helper for SkCanvas subclasses which do not need to
  14. // actually rasterize (e.g., analysis of the draw calls).
  15. //
  16. // It provides the following simplifications:
  17. //
  18. // * not backed by any device/pixels
  19. // * conservative clipping (clipping calls only use rectangles)
  20. //
  21. class SK_API SkNoDrawCanvas : public SkCanvasVirtualEnforcer<SkCanvas> {
  22. public:
  23. SkNoDrawCanvas(int width, int height);
  24. // TODO: investigate the users of this ctor.
  25. SkNoDrawCanvas(const SkIRect&);
  26. explicit SkNoDrawCanvas(sk_sp<SkBaseDevice> device);
  27. // Optimization to reset state to be the same as after construction.
  28. void resetCanvas(int width, int height) {
  29. resetForNextPicture(SkIRect::MakeWH(width, height));
  30. }
  31. protected:
  32. SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
  33. bool onDoSaveBehind(const SkRect*) override;
  34. // No-op overrides for aborting rasterization earlier than SkNullBlitter.
  35. void onDrawAnnotation(const SkRect&, const char[], SkData*) override {}
  36. void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {}
  37. void onDrawDrawable(SkDrawable*, const SkMatrix*) override {}
  38. void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
  39. void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
  40. const SkPaint&) override {}
  41. void onDrawPaint(const SkPaint&) override {}
  42. void onDrawBehind(const SkPaint&) override {}
  43. void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
  44. void onDrawRect(const SkRect&, const SkPaint&) override {}
  45. void onDrawRegion(const SkRegion&, const SkPaint&) override {}
  46. void onDrawOval(const SkRect&, const SkPaint&) override {}
  47. void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
  48. void onDrawRRect(const SkRRect&, const SkPaint&) override {}
  49. void onDrawPath(const SkPath&, const SkPaint&) override {}
  50. void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {}
  51. void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
  52. SrcRectConstraint) override {}
  53. void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
  54. void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
  55. SrcRectConstraint) override {}
  56. void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {}
  57. void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
  58. const SkPaint*) override {}
  59. void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
  60. const SkPaint*) override {}
  61. void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
  62. const SkPaint*) override {}
  63. void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone[], int, SkBlendMode,
  64. const SkPaint&) override {}
  65. void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
  66. int, SkBlendMode, const SkRect*, const SkPaint*) override {}
  67. void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
  68. void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
  69. void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, SkColor,
  70. SkBlendMode) override {}
  71. void onDrawEdgeAAImageSet(const ImageSetEntry[], int, const SkPoint[],
  72. const SkMatrix[], const SkPaint*, SrcRectConstraint) override {}
  73. private:
  74. typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
  75. };
  76. #endif // SkNoDrawCanvas_DEFINED