Dynamically create stencil buffer when needed.

Review URL: https://codereview.chromium.org/938383004
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index 49cea63..40e006a 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -12,6 +12,7 @@
 #include "SkRect.h"
 
 class GrStencilBuffer;
+class GrRenderTargetPriv;
 
 /**
  * GrRenderTarget represents a 2D buffer of pixels that can be rendered to.
@@ -88,11 +89,9 @@
     };
     virtual ResolveType getResolveType() const = 0;
 
-    /**
-     * GrStencilBuffer is not part of the public API.
-     */
-    GrStencilBuffer* getStencilBuffer() const { return fStencilBuffer; }
-    void setStencilBuffer(GrStencilBuffer* stencilBuffer);
+    // Provides access to functions that aren't part of the public API.
+    GrRenderTargetPriv renderTargetPriv();
+    const GrRenderTargetPriv renderTargetPriv() const;
 
 protected:
     GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc)
@@ -106,6 +105,11 @@
     void onRelease() SK_OVERRIDE;
 
 private:
+    // Checked when this object is asked to attach a stencil buffer.
+    virtual bool canAttemptStencilAttachment() const = 0;
+
+    friend class GrRenderTargetPriv;
+
     GrStencilBuffer*  fStencilBuffer;
 
     SkIRect           fResolveRect;