blob: ff17505972bd0de83ded1f3541c7692897c621e3 [file] [log] [blame]
Brian Osman11052242016-10-27 14:47:55 -04001/*
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
15class GrFixedClip;
16class GrPath;
17struct 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. */
22class GrRenderTargetContextPriv {
23public:
24 gr_instanced::InstancedRendering* accessInstancedRendering() const {
25 return fRenderTargetContext->getOpList()->instancedRendering();
26 }
27
csmartdalton7cdda992016-11-01 07:03:03 -070028 // called to note the last clip drawn to the stencil buffer.
29 // TODO: remove after clipping overhaul.
30 void setLastClip(int32_t clipStackGenID,
31 const SkIRect& clipSpaceRect,
32 const SkIPoint clipOrigin) {
33 GrRenderTargetOpList* opList = fRenderTargetContext->getOpList();
34 opList->fLastClipStackGenID = clipStackGenID;
35 opList->fLastClipStackRect = clipSpaceRect;
36 opList->fLastClipOrigin = clipOrigin;
37 }
38
39 // called to determine if we have to render the clip into SB.
40 // TODO: remove after clipping overhaul.
41 bool mustRenderClip(int32_t clipStackGenID,
42 const SkIRect& clipSpaceRect,
43 const SkIPoint& clipOrigin) const {
44 GrRenderTargetOpList* opList = fRenderTargetContext->getOpList();
45 return opList->fLastClipStackGenID != clipStackGenID ||
46 opList->fLastClipOrigin != clipOrigin ||
47 !opList->fLastClipStackRect.contains(clipSpaceRect);
48 }
49
Brian Osman11052242016-10-27 14:47:55 -040050 void clear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
51
52 void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
53
54 void stencilRect(const GrClip& clip,
55 const GrUserStencilSettings* ss,
56 bool useHWAA,
57 const SkMatrix& viewMatrix,
58 const SkRect& rect);
59
60 void stencilPath(const GrClip&,
61 bool useHWAA,
62 const SkMatrix& viewMatrix,
63 const GrPath*);
64
65 bool drawAndStencilRect(const GrClip&,
66 const GrUserStencilSettings*,
67 SkRegion::Op op,
68 bool invert,
69 bool doAA,
70 const SkMatrix& viewMatrix,
71 const SkRect&);
72
73 bool drawAndStencilPath(const GrClip&,
74 const GrUserStencilSettings*,
75 SkRegion::Op op,
76 bool invert,
77 bool doAA,
78 const SkMatrix& viewMatrix,
79 const SkPath&);
80
81 SkBudgeted isBudgeted() const;
82
Robert Phillipsec2249f2016-11-09 08:54:35 -050083 int maxWindowRectangles() const;
84
Robert Phillips294870f2016-11-11 12:38:40 -050085 /*
86 * This unique ID will not change for a given RenderTargetContext. However, it is _NOT_
87 * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
88 */
89 GrSurfaceProxy::UniqueID uniqueID() const {
90 return fRenderTargetContext->fRenderTargetProxy->uniqueID();
91 }
92
Brian Osman11052242016-10-27 14:47:55 -040093 void testingOnly_drawBatch(const GrPaint&,
Brian Salomon9afd3712016-12-01 10:59:09 -050094 GrDrawOp* batch,
Brian Osman11052242016-10-27 14:47:55 -040095 const GrUserStencilSettings* = nullptr,
96 bool snapToCenters = false);
97
98private:
99 explicit GrRenderTargetContextPriv(GrRenderTargetContext* renderTargetContext)
100 : fRenderTargetContext(renderTargetContext) {}
101 GrRenderTargetContextPriv(const GrRenderTargetPriv&) {} // unimpl
102 GrRenderTargetContextPriv& operator=(const GrRenderTargetPriv&); // unimpl
103
104 // No taking addresses of this type.
105 const GrRenderTargetContextPriv* operator&() const;
106 GrRenderTargetContextPriv* operator&();
107
108 GrRenderTargetContext* fRenderTargetContext;
109
110 friend class GrRenderTargetContext; // to construct/copy this type.
111};
112
Brian Osman693a5402016-10-27 15:13:22 -0400113inline GrRenderTargetContextPriv GrRenderTargetContext::priv() {
Brian Osman11052242016-10-27 14:47:55 -0400114 return GrRenderTargetContextPriv(this);
115}
116
Brian Osman693a5402016-10-27 15:13:22 -0400117inline const GrRenderTargetContextPriv GrRenderTargetContext::priv() const {
Brian Osman11052242016-10-27 14:47:55 -0400118 return GrRenderTargetContextPriv(const_cast<GrRenderTargetContext*>(this));
119}
120
121#endif