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 requestedConfig |
|
Chris Dalton
2015/03/14 02:51:30
Oops, sorry. I didn't finish my previous comment a
| |
| 35 * @return true if the surface is multisampled in all of the buffers | |
| 36 * specified by the sample config, false if any are non-MSAA | |
| 35 */ | 37 */ |
| 36 bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } | 38 bool isMultisampled(GrSampleConfig requestedConfig = kUnified_GrSampleConfig ) const { |
| 39 return 0 != numSamples(requestedConfig); | |
| 40 } | |
| 37 | 41 |
| 38 /** | 42 /** |
| 39 * @return the number of samples-per-pixel or zero if non-MSAA. | 43 * @return the number of samples-per-pixel or zero if any of the specified |
| 44 * buffers is non-MSAA. | |
| 40 */ | 45 */ |
| 41 int numSamples() const { return fDesc.fSampleCnt; } | 46 int numSamples(GrSampleConfig requestedConfig = kUnified_GrSampleConfig) con st { |
| 47 if (kStencil_GrSampleConfig == fSampleConfig && | |
| 48 kUnified_GrSampleConfig == requestedConfig) { | |
| 49 return 0; | |
| 50 } | |
| 51 return fDesc.fSampleCnt; | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * @return sample config. | |
| 56 */ | |
| 57 GrSampleConfig sampleConfig() { | |
| 58 return fSampleConfig; | |
| 59 } | |
| 42 | 60 |
| 43 /** | 61 /** |
| 44 * Call to indicate the multisample contents were modified such that the | 62 * 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 | 63 * 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 | 64 * 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 | 65 * when the render target has been modified outside of Gr. This has no |
| 48 * effect on wrapped backend render targets. | 66 * effect on wrapped backend render targets. |
| 49 * | 67 * |
| 50 * @param rect a rect bounding the area needing resolve. NULL indicates | 68 * @param rect a rect bounding the area needing resolve. NULL indicates |
| 51 * the whole RT needs resolving. | 69 * the whole RT needs resolving. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 kAutoResolves_ResolveType, | 105 kAutoResolves_ResolveType, |
| 88 kCantResolve_ResolveType, | 106 kCantResolve_ResolveType, |
| 89 }; | 107 }; |
| 90 virtual ResolveType getResolveType() const = 0; | 108 virtual ResolveType getResolveType() const = 0; |
| 91 | 109 |
| 92 // Provides access to functions that aren't part of the public API. | 110 // Provides access to functions that aren't part of the public API. |
| 93 GrRenderTargetPriv renderTargetPriv(); | 111 GrRenderTargetPriv renderTargetPriv(); |
| 94 const GrRenderTargetPriv renderTargetPriv() const; | 112 const GrRenderTargetPriv renderTargetPriv() const; |
| 95 | 113 |
| 96 protected: | 114 protected: |
| 97 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) | 115 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc, |
| 116 GrSampleConfig sampleConfig) | |
| 98 : INHERITED(gpu, lifeCycle, desc) | 117 : INHERITED(gpu, lifeCycle, desc) |
| 118 , fSampleConfig(sampleConfig) | |
| 99 , fStencilBuffer(NULL) { | 119 , fStencilBuffer(NULL) { |
| 100 fResolveRect.setLargestInverted(); | 120 fResolveRect.setLargestInverted(); |
| 101 } | 121 } |
| 102 | 122 |
| 103 // override of GrResource | 123 // override of GrResource |
| 104 void onAbandon() SK_OVERRIDE; | 124 void onAbandon() SK_OVERRIDE; |
| 105 void onRelease() SK_OVERRIDE; | 125 void onRelease() SK_OVERRIDE; |
| 106 | 126 |
| 107 private: | 127 private: |
| 108 // Checked when this object is asked to attach a stencil buffer. | 128 // Checked when this object is asked to attach a stencil buffer. |
| 109 virtual bool canAttemptStencilAttachment() const = 0; | 129 virtual bool canAttemptStencilAttachment() const = 0; |
| 110 | 130 |
| 111 friend class GrRenderTargetPriv; | 131 friend class GrRenderTargetPriv; |
| 112 | 132 |
| 133 GrSampleConfig fSampleConfig; | |
| 134 | |
| 113 GrStencilBuffer* fStencilBuffer; | 135 GrStencilBuffer* fStencilBuffer; |
| 114 | 136 |
| 115 SkIRect fResolveRect; | 137 SkIRect fResolveRect; |
| 116 | 138 |
| 117 typedef GrSurface INHERITED; | 139 typedef GrSurface INHERITED; |
| 118 }; | 140 }; |
| 119 | 141 |
| 120 #endif | 142 #endif |
| OLD | NEW |