Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrRenderTarget_DEFINED | 8 #ifndef GrRenderTarget_DEFINED |
| 9 #define GrRenderTarget_DEFINED | 9 #define GrRenderTarget_DEFINED |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 class GrRenderTarget : virtual public GrSurface { | 24 class GrRenderTarget : virtual public GrSurface { |
| 25 public: | 25 public: |
| 26 SK_DECLARE_INST_COUNT(GrRenderTarget) | 26 SK_DECLARE_INST_COUNT(GrRenderTarget) |
| 27 | 27 |
| 28 // GrSurface overrides | 28 // GrSurface overrides |
| 29 GrRenderTarget* asRenderTarget() SK_OVERRIDE { return this; } | 29 GrRenderTarget* asRenderTarget() SK_OVERRIDE { return this; } |
| 30 const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return this; } | 30 const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return this; } |
| 31 | 31 |
| 32 // GrRenderTarget | 32 // GrRenderTarget |
| 33 /** | 33 /** |
| 34 * @return true if the surface is multisampled, false otherwise | 34 * @param pipelineStage specifies the buffer(s) for which multisampling |
| 35 is queried | |
| 36 * @return true if the surface is multisampled in all of the buffers | |
| 37 * specified by the sample config, false if any are non-MSAA | |
| 35 */ | 38 */ |
|
Chris Dalton
2015/03/19 12:07:40
Maybe pipeline stage would be better to say than b
| |
| 36 bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } | 39 bool isMultisampled(GrPipelineStage pipelineStage = |
| 40 kEverywhere_GrPipelineStage) const { | |
| 41 return 0 != numSamples(pipelineStage); | |
| 42 } | |
| 37 | 43 |
| 38 /** | 44 /** |
| 39 * @return the number of samples-per-pixel or zero if non-MSAA. | 45 * @param pipelineStage specifies the buffer(s) for which sample count |
| 46 is queried | |
| 47 * @return the number of samples-per-pixel or zero if any of the specified | |
| 48 * buffers is non-MSAA. | |
| 40 */ | 49 */ |
| 41 int numSamples() const { return fDesc.fSampleCnt; } | 50 int numSamples(GrPipelineStage pipelineStage = |
| 51 kEverywhere_GrPipelineStage) const { | |
| 52 if (kStencil_GrSampleConfig == fSampleConfig && | |
| 53 kColorBuffer_GrPipelineStage == pipelineStage) { | |
| 54 return 0; | |
| 55 } | |
| 56 return fDesc.fSampleCnt; | |
| 57 } | |
| 58 | |
| 59 /** | |
| 60 * @return sample config: kUnified_GrSampleConfig if both color and stencil | |
| 61 buffers are MSAA, or kStencil_GrSampleConfig if only stencil | |
| 62 buffer is MSAA. | |
| 63 */ | |
| 64 GrSampleConfig sampleConfig() const { | |
| 65 return fSampleConfig; | |
| 66 } | |
| 42 | 67 |
| 43 /** | 68 /** |
| 44 * Call to indicate the multisample contents were modified such that the | 69 * Call to indicate the multisample contents were modified such that the |
| 45 * render target needs to be resolved before it can be used as texture. Gr | 70 * render target needs to be resolved before it can be used as texture. Gr |
| 46 * tracks this for its own drawing and thus this only needs to be called | 71 * tracks this for its own drawing and thus this only needs to be called |
| 47 * when the render target has been modified outside of Gr. This has no | 72 * when the render target has been modified outside of Gr. This has no |
| 48 * effect on wrapped backend render targets. | 73 * effect on wrapped backend render targets. |
| 49 * | 74 * |
| 50 * @param rect a rect bounding the area needing resolve. NULL indicates | 75 * @param rect a rect bounding the area needing resolve. NULL indicates |
| 51 * the whole RT needs resolving. | 76 * the whole RT needs resolving. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 kAutoResolves_ResolveType, | 112 kAutoResolves_ResolveType, |
| 88 kCantResolve_ResolveType, | 113 kCantResolve_ResolveType, |
| 89 }; | 114 }; |
| 90 virtual ResolveType getResolveType() const = 0; | 115 virtual ResolveType getResolveType() const = 0; |
| 91 | 116 |
| 92 // Provides access to functions that aren't part of the public API. | 117 // Provides access to functions that aren't part of the public API. |
| 93 GrRenderTargetPriv renderTargetPriv(); | 118 GrRenderTargetPriv renderTargetPriv(); |
| 94 const GrRenderTargetPriv renderTargetPriv() const; | 119 const GrRenderTargetPriv renderTargetPriv() const; |
| 95 | 120 |
| 96 protected: | 121 protected: |
| 97 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) | 122 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc, |
| 123 GrSampleConfig sampleConfig) | |
| 98 : INHERITED(gpu, lifeCycle, desc) | 124 : INHERITED(gpu, lifeCycle, desc) |
| 125 , fSampleConfig(sampleConfig) | |
| 99 , fStencilBuffer(NULL) { | 126 , fStencilBuffer(NULL) { |
| 100 fResolveRect.setLargestInverted(); | 127 fResolveRect.setLargestInverted(); |
| 101 } | 128 } |
| 102 | 129 |
| 103 // override of GrResource | 130 // override of GrResource |
| 104 void onAbandon() SK_OVERRIDE; | 131 void onAbandon() SK_OVERRIDE; |
| 105 void onRelease() SK_OVERRIDE; | 132 void onRelease() SK_OVERRIDE; |
| 106 | 133 |
| 107 private: | 134 private: |
| 108 // Checked when this object is asked to attach a stencil buffer. | 135 // Checked when this object is asked to attach a stencil buffer. |
| 109 virtual bool canAttemptStencilAttachment() const = 0; | 136 virtual bool canAttemptStencilAttachment() const = 0; |
| 110 | 137 |
| 111 friend class GrRenderTargetPriv; | 138 friend class GrRenderTargetPriv; |
| 112 | 139 |
| 140 GrSampleConfig fSampleConfig; | |
| 141 | |
| 113 GrStencilBuffer* fStencilBuffer; | 142 GrStencilBuffer* fStencilBuffer; |
| 114 | 143 |
| 115 SkIRect fResolveRect; | 144 SkIRect fResolveRect; |
| 116 | 145 |
| 117 typedef GrSurface INHERITED; | 146 typedef GrSurface INHERITED; |
| 118 }; | 147 }; |
| 119 | 148 |
| 120 #endif | 149 #endif |
| OLD | NEW |