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 * Pipeline stage serves as a query parameter to render target's isMultisamp led |
| 35 * and numSamples methods. It signifies whether the caller is interested in | |
| 36 * multisampling in color buffer or stencil buffer specifically, both, or an y of | |
| 37 * the two. Used by the NV_framebuffer_mixed_samples implementation. | |
|
Chris Dalton
2015/03/20 07:01:45
This comment should probably talk about the pipeli
| |
| 35 */ | 38 */ |
| 36 bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } | 39 enum PipelineStage { |
| 40 kColorBuffer_PipelineStage, | |
| 41 kStencilBuffer_PipelineStage, | |
|
Chris Dalton
2015/03/20 07:01:45
These equalities seem like they need a comment.
| |
| 42 kEverywhere_PipelineStage = kColorBuffer_PipelineStage, | |
| 43 kAnywhere_PipelineStage = kStencilBuffer_PipelineStage | |
| 44 }; | |
| 37 | 45 |
| 38 /** | 46 /** |
| 39 * @return the number of samples-per-pixel or zero if non-MSAA. | 47 * @param pipelineStage specifies the pipeline stage for which |
| 48 * multisampling is queried | |
| 49 * @return true if the surface is multisampled in all of the buffers | |
| 50 * specified by the sample config, false if any are non-MSAA | |
|
Chris Dalton
2015/03/20 07:01:45
"true if the surface is multisampled in the specif
| |
| 40 */ | 51 */ |
| 41 int numSamples() const { return fDesc.fSampleCnt; } | 52 bool isMultisampled(PipelineStage pipelineStage = |
| 53 kEverywhere_PipelineStage) const { | |
| 54 return 0 != numSamples(pipelineStage); | |
| 55 } | |
| 56 | |
| 57 /** | |
| 58 * @param pipelineStage specifies the pipeline stage for which | |
| 59 * multisampling is queried | |
| 60 * @return the number of samples-per-pixel or zero if any of the specified | |
| 61 * buffers is non-MSAA. | |
|
Chris Dalton
2015/03/20 07:01:45
"the number of samples-per-pixel, or zero if the r
| |
| 62 */ | |
| 63 int numSamples(PipelineStage pipelineStage = | |
| 64 kEverywhere_PipelineStage) const { | |
|
Chris Dalton
2015/03/20 07:01:45
Now I'm nit-picking, but I'm wondering if this fun
| |
| 65 if (kStencil_GrSampleConfig == fSampleConfig && | |
| 66 kColorBuffer_PipelineStage == pipelineStage) { | |
| 67 return 0; | |
| 68 } | |
| 69 return fDesc.fSampleCnt; | |
| 70 } | |
| 71 | |
| 72 /** | |
| 73 * @return sample config: kUnified_GrSampleConfig if both color and stencil | |
| 74 buffers are MSAA, or kStencil_GrSampleConfig if only stencil | |
| 75 buffer is MSAA. | |
| 76 */ | |
| 77 GrSampleConfig sampleConfig() const { | |
| 78 return fSampleConfig; | |
| 79 } | |
| 42 | 80 |
| 43 /** | 81 /** |
| 44 * Call to indicate the multisample contents were modified such that the | 82 * 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 | 83 * 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 | 84 * 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 | 85 * when the render target has been modified outside of Gr. This has no |
| 48 * effect on wrapped backend render targets. | 86 * effect on wrapped backend render targets. |
| 49 * | 87 * |
| 50 * @param rect a rect bounding the area needing resolve. NULL indicates | 88 * @param rect a rect bounding the area needing resolve. NULL indicates |
| 51 * the whole RT needs resolving. | 89 * the whole RT needs resolving. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 kAutoResolves_ResolveType, | 125 kAutoResolves_ResolveType, |
| 88 kCantResolve_ResolveType, | 126 kCantResolve_ResolveType, |
| 89 }; | 127 }; |
| 90 virtual ResolveType getResolveType() const = 0; | 128 virtual ResolveType getResolveType() const = 0; |
| 91 | 129 |
| 92 // Provides access to functions that aren't part of the public API. | 130 // Provides access to functions that aren't part of the public API. |
| 93 GrRenderTargetPriv renderTargetPriv(); | 131 GrRenderTargetPriv renderTargetPriv(); |
| 94 const GrRenderTargetPriv renderTargetPriv() const; | 132 const GrRenderTargetPriv renderTargetPriv() const; |
| 95 | 133 |
| 96 protected: | 134 protected: |
| 97 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) | 135 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc, |
| 136 GrSampleConfig sampleConfig) | |
| 98 : INHERITED(gpu, lifeCycle, desc) | 137 : INHERITED(gpu, lifeCycle, desc) |
| 138 , fSampleConfig(sampleConfig) | |
| 99 , fStencilBuffer(NULL) { | 139 , fStencilBuffer(NULL) { |
| 100 fResolveRect.setLargestInverted(); | 140 fResolveRect.setLargestInverted(); |
| 101 } | 141 } |
| 102 | 142 |
| 103 // override of GrResource | 143 // override of GrResource |
| 104 void onAbandon() SK_OVERRIDE; | 144 void onAbandon() SK_OVERRIDE; |
| 105 void onRelease() SK_OVERRIDE; | 145 void onRelease() SK_OVERRIDE; |
| 106 | 146 |
| 107 private: | 147 private: |
| 108 // Checked when this object is asked to attach a stencil buffer. | 148 // Checked when this object is asked to attach a stencil buffer. |
| 109 virtual bool canAttemptStencilAttachment() const = 0; | 149 virtual bool canAttemptStencilAttachment() const = 0; |
| 110 | 150 |
| 111 friend class GrRenderTargetPriv; | 151 friend class GrRenderTargetPriv; |
| 112 | 152 |
| 153 GrSampleConfig fSampleConfig; | |
| 154 | |
| 113 GrStencilBuffer* fStencilBuffer; | 155 GrStencilBuffer* fStencilBuffer; |
| 114 | 156 |
| 115 SkIRect fResolveRect; | 157 SkIRect fResolveRect; |
| 116 | 158 |
| 117 typedef GrSurface INHERITED; | 159 typedef GrSurface INHERITED; |
| 118 }; | 160 }; |
| 119 | 161 |
| 120 #endif | 162 #endif |
| OLD | NEW |