Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 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 | |
csmartdalton | 7cdda99 | 2016-11-01 07:03:03 -0700 | [diff] [blame] | 28 | // 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 Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 50 | 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 Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 83 | int maxWindowRectangles() const; |
| 84 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 85 | /* |
| 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 Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 93 | void testingOnly_drawBatch(const GrPaint&, |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 94 | GrDrawOp* batch, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 95 | const GrUserStencilSettings* = nullptr, |
| 96 | bool snapToCenters = false); |
| 97 | |
| 98 | private: |
| 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 Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 113 | inline GrRenderTargetContextPriv GrRenderTargetContext::priv() { |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 114 | return GrRenderTargetContextPriv(this); |
| 115 | } |
| 116 | |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 117 | inline const GrRenderTargetContextPriv GrRenderTargetContext::priv() const { |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 118 | return GrRenderTargetContextPriv(const_cast<GrRenderTargetContext*>(this)); |
| 119 | } |
| 120 | |
| 121 | #endif |