aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPipeline.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-26 09:12:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-26 15:35:12 +0000
commit493489054f85d1b7725412ad7a3cdc70c7ec5466 (patch)
tree45223f5039eefd3aba721d737cb70549baaa8d0d /src/gpu/GrPipeline.h
parentd5506cb888858bd19fa54be50714a8d661cedf33 (diff)
Refactor GrPipeline dynamic state.
Remove scissor rect from GrPipeline. Draws can specify "fixed dynamic state" which doesn't use the dynamism at all or can specify dynamic state arrays with an entry per GrMesh. When we state other than scissor rects this will allow the caller to use a mix of truly dynamic and fixed dynamic state. So a caller that only has dynamic scissor rects doesn't need to store its remaining unvarying state in an array. Change-Id: I8fcc07eb600c72a26cc712b185755c2116021a8a Reviewed-on: https://skia-review.googlesource.com/137223 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrPipeline.h')
-rw-r--r--src/gpu/GrPipeline.h28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index 3ace0f0a1c..f60a6d410b 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -79,16 +79,26 @@ public:
};
/**
- * Graphics state that can change dynamically without creating a new pipeline.
+ * Some state can be changed between GrMeshes without changing GrPipelines. This is generally
+ * less expensive then using multiple pipelines. Such state is called "dynamic state". It can
+ * be specified in two ways:
+ * 1) FixedDynamicState - use this to specify state that does not vary between GrMeshes.
+ * 2) DynamicStateArrays - use this to specify per mesh values for dynamic state.
**/
- struct DynamicState {
- // Overrides the scissor rectangle (if scissor is enabled in the pipeline).
- // TODO: eventually this should be the only way to specify a scissor rectangle, as is the
- // case with the simple constructor.
+ struct FixedDynamicState {
+ FixedDynamicState(const SkIRect& scissorRect) : fScissorRect(scissorRect) {}
SkIRect fScissorRect;
};
/**
+ * Any non-null array overrides the FixedDynamicState on a mesh-by-mesh basis. Arrays must
+ * have one entry for each GrMesh.
+ */
+ struct DynamicStateArrays {
+ const SkIRect* fScissorRects = nullptr;
+ };
+
+ /**
* Creates a simple pipeline with default settings and no processors. The provided blend mode
* must be "Porter Duff" (<= kLastCoeffMode). If using ScissorState::kEnabled, the caller must
* specify a scissor rectangle through the DynamicState struct.
@@ -169,7 +179,9 @@ public:
const GrUserStencilSettings* getUserStencil() const { return fUserStencilSettings; }
- const GrScissorState& getScissorState() const { return fScissorState; }
+ ScissorState isScissorEnabled() const {
+ return ScissorState(SkToBool(fFlags & kScissorEnabled_Flag));
+ }
const GrWindowRectsState& getWindowRectsState() const { return fWindowRectsState; }
@@ -214,7 +226,8 @@ private:
enum PrivateFlags {
kHasStencilClip_Flag = 0x10,
kStencilEnabled_Flag = 0x20,
- kIsBad_Flag = 0x40,
+ kScissorEnabled_Flag = 0x40,
+ kIsBad_Flag = 0x80,
};
using RenderTargetProxy = GrPendingIOResource<GrRenderTargetProxy, kWrite_GrIOType>;
@@ -225,7 +238,6 @@ private:
SkIPoint fDstTextureOffset;
// MDB TODO: do we still need the destination proxy here?
RenderTargetProxy fProxy;
- GrScissorState fScissorState;
GrWindowRectsState fWindowRectsState;
const GrUserStencilSettings* fUserStencilSettings;
uint16_t fFlags;