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

Unified Diff: src/gpu/GrDrawTarget.h

Issue 678683005: Scissor rect on drawinfo (Closed) Base URL: https://skia.googlesource.com/skia.git@clip_to_target
Patch Set: feedback inc Created 6 years, 2 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: src/gpu/GrDrawTarget.h
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 552314bca352f634879991bcfa3247c5340383b3..0581f303fd9b94db5b1d6963ca66731e6531910d 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -31,9 +31,6 @@ class GrPathRange;
class GrVertexBuffer;
class GrDrawTarget : public SkRefCnt {
-protected:
- class DrawInfo;
-
public:
SK_DECLARE_INST_COUNT(GrDrawTarget)
@@ -482,6 +479,8 @@ public:
*/
virtual void purgeResources() {};
+ class DrawInfo;
+
/**
* For subclass internal use to invoke a call to onDraw(). See DrawInfo below.
*/
@@ -693,6 +692,101 @@ public:
virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); }
+ /**
+ * Used to communicate draws to subclass's onDraw function.
+ * TODO move to its own .h file
+ */
+ class DrawInfo {
+ public:
+ DrawInfo(const DrawInfo& di) { (*this) = di; }
+ DrawInfo& operator =(const DrawInfo& di);
+
+ GrPrimitiveType primitiveType() const { return fPrimitiveType; }
+ int startVertex() const { return fStartVertex; }
+ int startIndex() const { return fStartIndex; }
+ int vertexCount() const { return fVertexCount; }
+ int indexCount() const { return fIndexCount; }
+ int verticesPerInstance() const { return fVerticesPerInstance; }
+ int indicesPerInstance() const { return fIndicesPerInstance; }
+ int instanceCount() const { return fInstanceCount; }
+
+ bool isIndexed() const { return fIndexCount > 0; }
+#ifdef SK_DEBUG
+ bool isInstanced() const; // this version is longer because of asserts
+#else
+ bool isInstanced() const { return fInstanceCount > 0; }
+#endif
+
+ // adds or remove instances
+ void adjustInstanceCount(int instanceOffset);
+ // shifts the start vertex
+ void adjustStartVertex(int vertexOffset);
+ // shifts the start index
+ void adjustStartIndex(int indexOffset);
+
+ void setDevBounds(const SkRect& bounds) {
+ fDevBoundsStorage = bounds;
+ fDevBounds = &fDevBoundsStorage;
+ }
+ const SkRect* getDevBounds() const { return fDevBounds; }
+
+ // NULL if no copy of the dst is needed for the draw.
+ const GrDeviceCoordTexture* getDstCopy() const {
+ if (fDstCopy.texture()) {
+ return &fDstCopy;
+ } else {
+ return NULL;
+ }
+ }
+
+ // The state of the scissor is controlled by the clip manager, no one else should set
+ // Scissor state
+ struct ScissorState {
+ ScissorState() : fEnabled(false) {}
+ bool fEnabled;
+ SkIRect fRect;
+ };
+
+ /**
+ * These methods are called by the clip manager's setupClipping function
+ * which (called as part of GrGpu's implementation of onDraw and
+ * onStencilPath member functions.) The GrGpu subclass should flush the
+ * stencil state to the 3D API in its implementation of flushGraphicsState.
+ */
+ void enableScissor(const SkIRect& rect) {
+ fScissorState.fEnabled = true;
+ fScissorState.fRect = rect;
+ }
+ void disableScissor() { fScissorState.fEnabled = false; }
+
+ const ScissorState& getScissor() const { return fScissorState; }
+
+ private:
+ DrawInfo() { fDevBounds = NULL; }
+
+ friend class GrDrawTarget;
+ // TODO make this its own class with setters and getters
+ friend class GrGpu;
+
+ GrPrimitiveType fPrimitiveType;
+
+ int fStartVertex;
+ int fStartIndex;
+ int fVertexCount;
+ int fIndexCount;
+
+ int fInstanceCount;
+ int fVerticesPerInstance;
+ int fIndicesPerInstance;
+
+ SkRect fDevBoundsStorage;
+ SkRect* fDevBounds;
+
+ GrDeviceCoordTexture fDstCopy;
+
+ ScissorState fScissorState;
+ };
+
protected:
// Extend access to GrDrawState::convertToPEndeingExec to subclasses.
void convertDrawStateToPendingExec(GrDrawState* ds) {
@@ -787,74 +881,6 @@ protected:
const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; }
- /**
- * Used to communicate draws to subclass's onDraw function.
- */
- class DrawInfo {
- public:
- DrawInfo(const DrawInfo& di) { (*this) = di; }
- DrawInfo& operator =(const DrawInfo& di);
-
- GrPrimitiveType primitiveType() const { return fPrimitiveType; }
- int startVertex() const { return fStartVertex; }
- int startIndex() const { return fStartIndex; }
- int vertexCount() const { return fVertexCount; }
- int indexCount() const { return fIndexCount; }
- int verticesPerInstance() const { return fVerticesPerInstance; }
- int indicesPerInstance() const { return fIndicesPerInstance; }
- int instanceCount() const { return fInstanceCount; }
-
- bool isIndexed() const { return fIndexCount > 0; }
-#ifdef SK_DEBUG
- bool isInstanced() const; // this version is longer because of asserts
-#else
- bool isInstanced() const { return fInstanceCount > 0; }
-#endif
-
- // adds or remove instances
- void adjustInstanceCount(int instanceOffset);
- // shifts the start vertex
- void adjustStartVertex(int vertexOffset);
- // shifts the start index
- void adjustStartIndex(int indexOffset);
-
- void setDevBounds(const SkRect& bounds) {
- fDevBoundsStorage = bounds;
- fDevBounds = &fDevBoundsStorage;
- }
- const SkRect* getDevBounds() const { return fDevBounds; }
-
- // NULL if no copy of the dst is needed for the draw.
- const GrDeviceCoordTexture* getDstCopy() const {
- if (fDstCopy.texture()) {
- return &fDstCopy;
- } else {
- return NULL;
- }
- }
-
- private:
- DrawInfo() { fDevBounds = NULL; }
-
- friend class GrDrawTarget;
-
- GrPrimitiveType fPrimitiveType;
-
- int fStartVertex;
- int fStartIndex;
- int fVertexCount;
- int fIndexCount;
-
- int fInstanceCount;
- int fVerticesPerInstance;
- int fIndicesPerInstance;
-
- SkRect fDevBoundsStorage;
- SkRect* fDevBounds;
-
- GrDeviceCoordTexture fDstCopy;
- };
-
// Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required
// but couldn't be made. Otherwise, returns true. This method needs to be protected because it
// needs to be accessed by GLPrograms to setup a correct drawstate
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrGpu.h » ('j') | src/gpu/GrGpu.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698