Add a basic constructor to GrPipeline
authorcsmartdalton <csmartdalton@google.com>
Wed, 8 Feb 2017 19:41:05 +0000 (14:41 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 8 Feb 2017 21:36:55 +0000 (21:36 +0000)
Adds a simple constructor for when we just need to set up basic
internal rendering.

BUG=skia:

Change-Id: Ib046c62e9a759aa7d0a3345e16ccf6e6af9342ea
Reviewed-on: https://skia-review.googlesource.com/8121
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>

include/gpu/effects/GrPorterDuffXferProcessor.h
src/gpu/GrPipeline.cpp
src/gpu/GrPipeline.h
src/gpu/effects/GrPorterDuffXferProcessor.cpp

index 028cac6..6c989b0 100644 (file)
@@ -33,6 +33,10 @@ public:
                                                        const GrPipelineAnalysis&,
                                                        bool hasMixedSamples,
                                                        const GrXferProcessor::DstTexture*);
+
+    /** Returns a simple non-LCD porter duff blend XP with no optimizations or coverage. */
+    static sk_sp<GrXferProcessor> CreateNoCoverageXP(SkBlendMode);
+
     /** This XP implements non-LCD src-over using hw blend with no optimizations. It is returned
         by reference because it is global and its ref-cnting methods are not thread safe. */
     static const GrXferProcessor& SimpleSrcOverXP();
index af8529a..d0c198f 100644 (file)
@@ -192,6 +192,18 @@ void GrPipeline::addDependenciesTo(GrRenderTarget* rt) const {
     }
 }
 
+GrPipeline::GrPipeline(GrRenderTarget* rt, SkBlendMode blendmode)
+    : fRenderTarget(rt)
+    , fScissorState()
+    , fWindowRectsState()
+    , fUserStencilSettings(&GrUserStencilSettings::kUnused)
+    , fDrawFace(static_cast<uint16_t>(GrDrawFace::kBoth))
+    , fFlags()
+    , fXferProcessor(GrPorterDuffXPFactory::CreateNoCoverageXP(blendmode).get())
+    , fFragmentProcessors()
+    , fNumColorProcessors(0) {
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 
 bool GrPipeline::AreEqual(const GrPipeline& a, const GrPipeline& b) {
index 3949a75..11de747 100644 (file)
@@ -100,6 +100,12 @@ public:
     /** Creates a pipeline into a pre-allocated buffer */
     static GrPipeline* CreateAt(void* memory, const CreateArgs&, GrPipelineOptimizations*);
 
+    /**
+     * Creates a simple pipeline with default settings and no processors. The provided blend mode
+     * must be "Porter Duff" (<= kLastCoeffMode).
+     **/
+    GrPipeline(GrRenderTarget*, SkBlendMode);
+
     /// @}
 
     ///////////////////////////////////////////////////////////////////////////
index 8289561..73c6ef4 100644 (file)
@@ -900,6 +900,11 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
     return new PorterDuffXferProcessor(blendFormula);
 }
 
+sk_sp<GrXferProcessor> GrPorterDuffXPFactory::CreateNoCoverageXP(SkBlendMode blendmode) {
+    BlendFormula formula = get_blend_formula(false, false, false, blendmode);
+    return sk_make_sp<PorterDuffXferProcessor>(formula);
+}
+
 bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps,
                                                       const GrPipelineAnalysis& analysis) {
     if (caps.shaderCaps()->dstReadInShaderSupport() ||