Line data Source code
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 :
8 : #ifndef GrRenderTargetContextPriv_DEFINED
9 : #define GrRenderTargetContextPriv_DEFINED
10 :
11 : #include "GrRenderTargetContext.h"
12 : #include "GrRenderTargetOpList.h"
13 : #include "GrPathRendering.h"
14 :
15 : class GrFixedClip;
16 : class GrPath;
17 : struct GrUserStencilSettings;
18 :
19 : /** Class that adds methods to GrRenderTargetContext that are only intended for use internal to
20 : Skia. This class is purely a privileged window into GrRenderTargetContext. It should never have
21 : additional data members or virtual methods. */
22 : class GrRenderTargetContextPriv {
23 : public:
24 : gr_instanced::InstancedRendering* accessInstancedRendering() const {
25 : return fRenderTargetContext->getOpList()->instancedRendering();
26 : }
27 :
28 : // called to note the last clip drawn to the stencil buffer.
29 : // TODO: remove after clipping overhaul.
30 0 : void setLastClip(int32_t clipStackGenID, const SkIRect& devClipBounds) {
31 0 : GrRenderTargetOpList* opList = fRenderTargetContext->getOpList();
32 0 : opList->fLastClipStackGenID = clipStackGenID;
33 0 : opList->fLastDevClipBounds = devClipBounds;
34 0 : }
35 :
36 : // called to determine if we have to render the clip into SB.
37 : // TODO: remove after clipping overhaul.
38 0 : bool mustRenderClip(int32_t clipStackGenID, const SkIRect& devClipBounds) const {
39 0 : GrRenderTargetOpList* opList = fRenderTargetContext->getOpList();
40 0 : return opList->fLastClipStackGenID != clipStackGenID ||
41 0 : !opList->fLastDevClipBounds.contains(devClipBounds);
42 : }
43 :
44 : void clear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
45 :
46 : void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
47 :
48 : /*
49 : * Some portions of the code, which use approximate-match rendertargets (i.e., ImageFilters),
50 : * rely on clears that lie outside of the content region to still have an effect.
51 : * For example, when sampling a decimated blurred image back up to full size, the GaussianBlur
52 : * code draws 1-pixel rects along the left and bottom edges to be able to use bilerp for
53 : * upsampling. The "absClear" entry point ignores the content bounds but does use the
54 : * worst case (instantiated) bounds.
55 : *
56 : * @param rect if (!null) the rect to clear, otherwise it is a full screen clear
57 : * @param color the color to clear to
58 : */
59 : void absClear(const SkIRect* rect, const GrColor color);
60 :
61 : void stencilRect(const GrClip& clip,
62 : const GrUserStencilSettings* ss,
63 : GrAAType,
64 : const SkMatrix& viewMatrix,
65 : const SkRect& rect);
66 :
67 : void stencilPath(const GrClip&, GrAAType, const SkMatrix& viewMatrix, const GrPath*);
68 :
69 : /**
70 : * Draws a rect, either AA or not, and touches the stencil buffer with the user stencil settings
71 : * for each color sample written.
72 : */
73 : bool drawAndStencilRect(const GrClip&,
74 : const GrUserStencilSettings*,
75 : SkRegion::Op op,
76 : bool invert,
77 : GrAA,
78 : const SkMatrix& viewMatrix,
79 : const SkRect&);
80 :
81 : /**
82 : * Draws a path, either AA or not, and touches the stencil buffer with the user stencil settings
83 : * for each color sample written.
84 : */
85 : bool drawAndStencilPath(const GrClip&,
86 : const GrUserStencilSettings*,
87 : SkRegion::Op op,
88 : bool invert,
89 : GrAA,
90 : const SkMatrix& viewMatrix,
91 : const SkPath&);
92 :
93 : SkBudgeted isBudgeted() const;
94 :
95 : int maxWindowRectangles() const;
96 :
97 : /*
98 : * This unique ID will not change for a given RenderTargetContext. However, it is _NOT_
99 : * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
100 : */
101 : GrSurfaceProxy::UniqueID uniqueID() const {
102 : return fRenderTargetContext->fRenderTargetProxy->uniqueID();
103 : }
104 :
105 : uint32_t testingOnly_addLegacyMeshDrawOp(GrPaint&&, GrAAType,
106 : std::unique_ptr<GrLegacyMeshDrawOp>,
107 : const GrUserStencilSettings* = nullptr,
108 : bool snapToCenters = false);
109 :
110 0 : bool refsWrappedObjects() const {
111 0 : return fRenderTargetContext->fRenderTargetProxy->refsWrappedObjects();
112 : }
113 :
114 : private:
115 0 : explicit GrRenderTargetContextPriv(GrRenderTargetContext* renderTargetContext)
116 0 : : fRenderTargetContext(renderTargetContext) {}
117 : GrRenderTargetContextPriv(const GrRenderTargetPriv&) {} // unimpl
118 : GrRenderTargetContextPriv& operator=(const GrRenderTargetPriv&); // unimpl
119 :
120 : // No taking addresses of this type.
121 : const GrRenderTargetContextPriv* operator&() const;
122 : GrRenderTargetContextPriv* operator&();
123 :
124 : GrRenderTargetContext* fRenderTargetContext;
125 :
126 : friend class GrRenderTargetContext; // to construct/copy this type.
127 : };
128 :
129 0 : inline GrRenderTargetContextPriv GrRenderTargetContext::priv() {
130 0 : return GrRenderTargetContextPriv(this);
131 : }
132 :
133 : inline const GrRenderTargetContextPriv GrRenderTargetContext::priv() const {
134 : return GrRenderTargetContextPriv(const_cast<GrRenderTargetContext*>(this));
135 : }
136 :
137 : #endif
|