OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrTest.h" | 9 #include "GrTest.h" |
10 | 10 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 #include "GrBufferAllocPool.h" | 136 #include "GrBufferAllocPool.h" |
137 #include "GrInOrderDrawBuffer.h" | 137 #include "GrInOrderDrawBuffer.h" |
138 #include "GrGpu.h" | 138 #include "GrGpu.h" |
139 | 139 |
140 class GrPipeline; | 140 class GrPipeline; |
141 | 141 |
142 class MockGpu : public GrGpu { | 142 class MockGpu : public GrGpu { |
143 public: | 143 public: |
144 MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrDrawT
argetCaps)); } | 144 MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrDrawT
argetCaps)); } |
145 ~MockGpu() SK_OVERRIDE {} | 145 ~MockGpu() override {} |
146 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
SK_OVERRIDE { | 146 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
override { |
147 return true; | 147 return true; |
148 } | 148 } |
149 | 149 |
150 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, | 150 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
151 int left, int top, | 151 int left, int top, |
152 int width, int height, | 152 int width, int height, |
153 GrPixelConfig config, | 153 GrPixelConfig config, |
154 size_t rowBytes) const SK_OVERRIDE { return f
alse; } | 154 size_t rowBytes) const override { return fals
e; } |
155 void buildProgramDesc(GrProgramDesc*,const GrPrimitiveProcessor&, | 155 void buildProgramDesc(GrProgramDesc*,const GrPrimitiveProcessor&, |
156 const GrPipeline&, | 156 const GrPipeline&, |
157 const GrBatchTracker&) const SK_OVERRIDE {} | 157 const GrBatchTracker&) const override {} |
158 | 158 |
159 void discard(GrRenderTarget*) SK_OVERRIDE {} | 159 void discard(GrRenderTarget*) override {} |
160 | 160 |
161 bool canCopySurface(const GrSurface* dst, | 161 bool canCopySurface(const GrSurface* dst, |
162 const GrSurface* src, | 162 const GrSurface* src, |
163 const SkIRect& srcRect, | 163 const SkIRect& srcRect, |
164 const SkIPoint& dstPoint) SK_OVERRIDE { return false; }; | 164 const SkIPoint& dstPoint) override { return false; }; |
165 | 165 |
166 bool copySurface(GrSurface* dst, | 166 bool copySurface(GrSurface* dst, |
167 GrSurface* src, | 167 GrSurface* src, |
168 const SkIRect& srcRect, | 168 const SkIRect& srcRect, |
169 const SkIPoint& dstPoint) SK_OVERRIDE { return false; }; | 169 const SkIPoint& dstPoint) override { return false; }; |
170 | 170 |
171 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OV
ERRIDE { | 171 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) overr
ide { |
172 return false; | 172 return false; |
173 } | 173 } |
174 | 174 |
175 private: | 175 private: |
176 void onResetContext(uint32_t resetBits) SK_OVERRIDE {} | 176 void onResetContext(uint32_t resetBits) override {} |
177 | 177 |
178 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, bool budgeted, const v
oid* srcData, | 178 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, bool budgeted, const v
oid* srcData, |
179 size_t rowBytes) SK_OVERRIDE { | 179 size_t rowBytes) override { |
180 return NULL; | 180 return NULL; |
181 } | 181 } |
182 | 182 |
183 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, bool budgete
d, | 183 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, bool budgete
d, |
184 const void* srcData) SK_OVERRIDE { | 184 const void* srcData) override { |
185 return NULL; | 185 return NULL; |
186 } | 186 } |
187 | 187 |
188 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE { r
eturn NULL; } | 188 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) override { retu
rn NULL; } |
189 | 189 |
190 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
SK_OVERRIDE { | 190 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
override { |
191 return NULL; | 191 return NULL; |
192 } | 192 } |
193 | 193 |
194 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE
{ return NULL; } | 194 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override { r
eturn NULL; } |
195 | 195 |
196 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE {
return NULL; } | 196 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override { ret
urn NULL; } |
197 | 197 |
198 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 198 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
199 bool canIgnoreRect) SK_OVERRIDE {} | 199 bool canIgnoreRect) override {} |
200 | 200 |
201 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) SK_OVERRIDE {} | 201 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override {} |
202 | 202 |
203 void onDraw(const DrawArgs&, const GrDrawTarget::DrawInfo&) SK_OVERRIDE {} | 203 void onDraw(const DrawArgs&, const GrDrawTarget::DrawInfo&) override {} |
204 | 204 |
205 void onStencilPath(const GrPath* path, const StencilPathState& state) SK_OVE
RRIDE {} | 205 void onStencilPath(const GrPath* path, const StencilPathState& state) overri
de {} |
206 | 206 |
207 void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) SK
_OVERRIDE {} | 207 void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) ov
erride {} |
208 | 208 |
209 void onDrawPaths(const DrawArgs&, | 209 void onDrawPaths(const DrawArgs&, |
210 const GrPathRange*, | 210 const GrPathRange*, |
211 const void* indices, | 211 const void* indices, |
212 GrDrawTarget::PathIndexType, | 212 GrDrawTarget::PathIndexType, |
213 const float transformValues[], | 213 const float transformValues[], |
214 GrDrawTarget::PathTransformType, | 214 GrDrawTarget::PathTransformType, |
215 int count, | 215 int count, |
216 const GrStencilSettings&) SK_OVERRIDE {} | 216 const GrStencilSettings&) override {} |
217 | 217 |
218 bool onReadPixels(GrRenderTarget* target, | 218 bool onReadPixels(GrRenderTarget* target, |
219 int left, int top, int width, int height, | 219 int left, int top, int width, int height, |
220 GrPixelConfig, | 220 GrPixelConfig, |
221 void* buffer, | 221 void* buffer, |
222 size_t rowBytes) SK_OVERRIDE { | 222 size_t rowBytes) override { |
223 return false; | 223 return false; |
224 } | 224 } |
225 | 225 |
226 bool onWriteTexturePixels(GrTexture* texture, | 226 bool onWriteTexturePixels(GrTexture* texture, |
227 int left, int top, int width, int height, | 227 int left, int top, int width, int height, |
228 GrPixelConfig config, const void* buffer, | 228 GrPixelConfig config, const void* buffer, |
229 size_t rowBytes) SK_OVERRIDE { | 229 size_t rowBytes) override { |
230 return false; | 230 return false; |
231 } | 231 } |
232 | 232 |
233 void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE { return; } | 233 void onResolveRenderTarget(GrRenderTarget* target) override { return; } |
234 | 234 |
235 bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, int heig
ht) SK_OVERRIDE { | 235 bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, int heig
ht) override { |
236 return false; | 236 return false; |
237 } | 237 } |
238 | 238 |
239 bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTarget*) SK
_OVERRIDE { | 239 bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTarget*) ov
erride { |
240 return false; | 240 return false; |
241 } | 241 } |
242 | 242 |
243 void clearStencil(GrRenderTarget* target) SK_OVERRIDE {} | 243 void clearStencil(GrRenderTarget* target) override {} |
244 | 244 |
245 void didAddGpuTraceMarker() SK_OVERRIDE {} | 245 void didAddGpuTraceMarker() override {} |
246 | 246 |
247 void didRemoveGpuTraceMarker() SK_OVERRIDE {} | 247 void didRemoveGpuTraceMarker() override {} |
248 | 248 |
249 typedef GrGpu INHERITED; | 249 typedef GrGpu INHERITED; |
250 }; | 250 }; |
251 | 251 |
252 GrContext* GrContext::CreateMockContext() { | 252 GrContext* GrContext::CreateMockContext() { |
253 GrContext* context = SkNEW_ARGS(GrContext, (Options())); | 253 GrContext* context = SkNEW_ARGS(GrContext, (Options())); |
254 | 254 |
255 context->initMockContext(); | 255 context->initMockContext(); |
256 return context; | 256 return context; |
257 } | 257 } |
258 | 258 |
259 void GrContext::initMockContext() { | 259 void GrContext::initMockContext() { |
260 SkASSERT(NULL == fGpu); | 260 SkASSERT(NULL == fGpu); |
261 fGpu = SkNEW_ARGS(MockGpu, (this)); | 261 fGpu = SkNEW_ARGS(MockGpu, (this)); |
262 SkASSERT(fGpu); | 262 SkASSERT(fGpu); |
263 this->initCommon(); | 263 this->initCommon(); |
264 | 264 |
265 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 265 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
266 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 266 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
267 // resources in the buffer pools. | 267 // resources in the buffer pools. |
268 SkDELETE(fDrawBuffer); | 268 SkDELETE(fDrawBuffer); |
269 SkDELETE(fDrawBufferVBAllocPool); | 269 SkDELETE(fDrawBufferVBAllocPool); |
270 SkDELETE(fDrawBufferIBAllocPool); | 270 SkDELETE(fDrawBufferIBAllocPool); |
271 | 271 |
272 fDrawBuffer = NULL; | 272 fDrawBuffer = NULL; |
273 fDrawBufferVBAllocPool = NULL; | 273 fDrawBufferVBAllocPool = NULL; |
274 fDrawBufferIBAllocPool = NULL; | 274 fDrawBufferIBAllocPool = NULL; |
275 } | 275 } |
OLD | NEW |