Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: include/gpu/GrContext.h

Issue 936943002: Pass clip to context (Closed) Base URL: https://skia.googlesource.com/skia.git@pass_down_rendertarget
Patch Set: feedback inc Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/gpu/GrContext.h
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 2433b89189d60fc43e84e6dae4f893b143fa7e3b..6a225c2538b0c057c19fd26ab42bfe3d22b49030 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -362,20 +362,6 @@ public:
GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
///////////////////////////////////////////////////////////////////////////
- // Clip state
- /**
- * Gets the current clip.
- * @return the current clip.
- */
- const GrClip* getClip() const { return fClip; }
-
- /**
- * Sets the clip.
- * @param clipData the clip to set.
- */
- void setClip(const GrClip* clipData) { fClip = clipData; }
-
- ///////////////////////////////////////////////////////////////////////////
// Draws
/**
@@ -391,7 +377,7 @@ public:
/**
* Draw everywhere (respecting the clip) with the paint.
*/
- void drawPaint(GrRenderTarget*, const GrPaint&, const SkMatrix& viewMatrix);
+ void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
/**
* Draw the rect using a paint.
@@ -406,6 +392,7 @@ public:
* The rects coords are used to access the paint (through texture matrix)
*/
void drawRect(GrRenderTarget*,
+ const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect&,
@@ -422,6 +409,7 @@ public:
* to rectToDraw
*/
void drawNonAARectToRect(GrRenderTarget*,
+ const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
@@ -432,11 +420,12 @@ public:
* Draws a non-AA rect with paint and a localMatrix
*/
void drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
+ const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix) {
- this->drawNonAARectToRect(rt, paint, viewMatrix, rect, rect, &localMatrix);
+ this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &localMatrix);
}
/**
@@ -449,6 +438,7 @@ public:
* the dash information (intervals, count, phase).
*/
void drawRRect(GrRenderTarget*,
+ const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
@@ -465,6 +455,7 @@ public:
* @param inner the inner roundrect
*/
void drawDRRect(GrRenderTarget*,
+ const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkRRect& outer,
@@ -481,6 +472,7 @@ public:
* the dash information (intervals, count, phase).
*/
void drawPath(GrRenderTarget*,
+ const GrClip&,
const GrPaint&,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -504,6 +496,7 @@ public:
* number of indices.
*/
void drawVertices(GrRenderTarget*,
+ const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
@@ -524,6 +517,7 @@ public:
* the dash information (intervals, count, phase).
*/
void drawOval(GrRenderTarget*,
+ const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
@@ -666,59 +660,6 @@ public:
#endif
///////////////////////////////////////////////////////////////////////////
- // Helpers
-
- class AutoClip : public ::SkNoncopyable {
- public:
- // This enum exists to require a caller of the constructor to acknowledge that the clip will
- // initially be wide open. It also could be extended if there are other desirable initial
- // clip states.
- enum InitialClip {
- kWideOpen_InitialClip,
- };
-
- AutoClip(GrContext* context, InitialClip SkDEBUGCODE(initialState))
- : fContext(context) {
- SkASSERT(kWideOpen_InitialClip == initialState);
- fNewClipData.setClipStack(&fNewClipStack);
-
- fOldClip = context->getClip();
- context->setClip(&fNewClipData);
- }
-
- AutoClip(GrContext* context, const SkRect& newClipRect)
- : fContext(context)
- , fNewClipStack(newClipRect) {
- fNewClipData.setClipStack(&fNewClipStack);
-
- fOldClip = fContext->getClip();
- fContext->setClip(&fNewClipData);
- }
-
- ~AutoClip() {
- if (fContext) {
- fContext->setClip(fOldClip);
- }
- }
- private:
- GrContext* fContext;
- const GrClip* fOldClip;
-
- SkClipStack fNewClipStack;
- GrClip fNewClipData;
- };
-
- class AutoWideOpenIdentityDraw {
- public:
- AutoWideOpenIdentityDraw(GrContext* ctx)
- : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) {
- }
-
- private:
- AutoClip fAutoClip;
- };
-
- ///////////////////////////////////////////////////////////////////////////
// Functions intended for internal use only.
GrGpu* getGpu() { return fGpu; }
const GrGpu* getGpu() const { return fGpu; }
@@ -761,7 +702,6 @@ public:
private:
GrGpu* fGpu;
- const GrClip* fClip;
GrResourceCache* fResourceCache;
GrFontCache* fFontCache;
@@ -802,11 +742,16 @@ private:
void setupDrawBuffer();
class AutoCheckFlush;
- // Sets the paint and returns the target to draw into. This function is overloaded to either
- // take a GrDrawState, GrPaint, and AutoCheckFlush, or JUST an AutoCheckFlush
- GrDrawTarget* prepareToDraw(GrPipelineBuilder*, GrRenderTarget* rt, const GrPaint* paint,
+ // Sets the paint and returns the target to draw into.
+ GrDrawTarget* prepareToDraw(GrPipelineBuilder*,
+ GrRenderTarget* rt,
+ const GrClip&,
+ const GrPaint* paint,
const AutoCheckFlush*);
+ // A simpler version of the above which just returns the draw target. Clip is *NOT* set
+ GrDrawTarget* prepareToDraw();
+
void internalDrawPath(GrDrawTarget*,
GrPipelineBuilder*,
const SkMatrix& viewMatrix,
« no previous file with comments | « include/gpu/GrClip.h ('k') | src/core/SkImageFilter.cpp » ('j') | src/gpu/GrTextContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698