OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "GrTest.h" | 8 #include "GrTest.h" |
10 | 9 |
11 #include "GrBatchAtlas.h" | 10 #include "GrBatchAtlas.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 public: | 261 public: |
263 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { | 262 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { |
264 fCaps.reset(new GrCaps(options)); | 263 fCaps.reset(new GrCaps(options)); |
265 } | 264 } |
266 ~MockGpu() override {} | 265 ~MockGpu() override {} |
267 | 266 |
268 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 267 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
269 GrPixelConfig readConfig, DrawPreference*, | 268 GrPixelConfig readConfig, DrawPreference*, |
270 ReadPixelTempDrawInfo*) override { return false; } | 269 ReadPixelTempDrawInfo*) override { return false; } |
271 | 270 |
272 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, size
_t rowBytes, | 271 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
273 GrPixelConfig srcConfig, DrawPreference*, | 272 GrPixelConfig srcConfig, DrawPreference*, |
274 WritePixelTempDrawInfo*) override { return false;
} | 273 WritePixelTempDrawInfo*) override { return false;
} |
275 | 274 |
276 void buildProgramDesc(GrProgramDesc*, const GrPrimitiveProcessor&, | 275 void buildProgramDesc(GrProgramDesc*, const GrPrimitiveProcessor&, |
277 const GrPipeline&) const override {} | 276 const GrPipeline&) const override {} |
278 | 277 |
279 void discard(GrRenderTarget*) override {} | 278 void discard(GrRenderTarget*) override {} |
280 | 279 |
281 bool onCopySurface(GrSurface* dst, | 280 bool onCopySurface(GrSurface* dst, |
282 GrSurface* src, | 281 GrSurface* src, |
283 const SkIRect& srcRect, | 282 const SkIRect& srcRect, |
284 const SkIPoint& dstPoint) override { return false; }; | 283 const SkIPoint& dstPoint) override { return false; }; |
285 | 284 |
286 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override { | 285 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override { |
287 return false; | 286 return false; |
288 } | 287 } |
289 | 288 |
290 void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) override {}
; | 289 void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) override {}
; |
291 | 290 |
292 private: | 291 private: |
293 void onResetContext(uint32_t resetBits) override {} | 292 void onResetContext(uint32_t resetBits) override {} |
294 | 293 |
295 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} | 294 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} |
296 | 295 |
297 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 296 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
298 const void* srcData, size_t rowBytes) override { | 297 const SkTArray<SkMipMapLevel>& texels) override { |
299 return nullptr; | 298 return nullptr; |
300 } | 299 } |
301 | 300 |
302 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, | 301 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, |
303 const void* srcData) override { | 302 const SkTArray<SkMipMapLevel>& texels)
override { |
304 return nullptr; | 303 return nullptr; |
305 } | 304 } |
306 | 305 |
307 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, | 306 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, |
308 GrWrapOwnership) override { return nullptr;
} | 307 GrWrapOwnership) override { return nullptr;
} |
309 | 308 |
310 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 309 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
311 GrWrapOwnership) override { | 310 GrWrapOwnership) override { |
312 return nullptr; | 311 return nullptr; |
313 } | 312 } |
(...skipping 13 matching lines...) Expand all Loading... |
327 bool onReadPixels(GrSurface* surface, | 326 bool onReadPixels(GrSurface* surface, |
328 int left, int top, int width, int height, | 327 int left, int top, int width, int height, |
329 GrPixelConfig, | 328 GrPixelConfig, |
330 void* buffer, | 329 void* buffer, |
331 size_t rowBytes) override { | 330 size_t rowBytes) override { |
332 return false; | 331 return false; |
333 } | 332 } |
334 | 333 |
335 bool onWritePixels(GrSurface* surface, | 334 bool onWritePixels(GrSurface* surface, |
336 int left, int top, int width, int height, | 335 int left, int top, int width, int height, |
337 GrPixelConfig config, const void* buffer, | 336 GrPixelConfig config, const SkTArray<SkMipMapLevel>& texe
ls) override { |
338 size_t rowBytes) override { | |
339 return false; | 337 return false; |
340 } | 338 } |
341 | 339 |
342 bool onTransferPixels(GrSurface* surface, | 340 bool onTransferPixels(GrSurface* surface, |
343 int left, int top, int width, int height, | 341 int left, int top, int width, int height, |
344 GrPixelConfig config, GrTransferBuffer* buffer, | 342 GrPixelConfig config, GrTransferBuffer* buffer, |
345 size_t offset, size_t rowBytes) override { | 343 size_t offset, size_t rowBytes) override { |
346 return false; | 344 return false; |
347 } | 345 } |
348 | 346 |
349 void onResolveRenderTarget(GrRenderTarget* target) override { return; } | 347 void onResolveRenderTarget(GrRenderTarget* target) override { return; } |
350 | 348 |
351 GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTa
rget*, | 349 GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTa
rget*, |
352 int width, | 350 int width, |
353 int height) over
ride { | 351 int height) over
ride { |
354 return nullptr; | 352 return nullptr; |
355 } | 353 } |
356 | 354 |
357 void clearStencil(GrRenderTarget* target) override {} | 355 void clearStencil(GrRenderTarget* target) override {} |
358 | 356 |
359 GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, | 357 GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, |
360 GrPixelConfig config) const
override { | 358 GrPixelConfig config) const
override { |
361 return 0; | 359 return 0; |
362 } | 360 } |
363 bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return f
alse; } | 361 bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return f
alse; } |
364 void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) c
onst override {} | 362 void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) c
onst override {} |
365 | 363 |
366 typedef GrGpu INHERITED; | 364 typedef GrGpu INHERITED; |
367 }; | 365 }; |
368 | 366 |
369 GrContext* GrContext::CreateMockContext() { | 367 GrContext* GrContext::CreateMockContext() { |
370 GrContext* context = new GrContext; | 368 GrContext* context = new GrContext; |
371 | 369 |
372 context->initMockContext(); | 370 context->initMockContext(); |
373 return context; | 371 return context; |
374 } | 372 } |
375 | 373 |
376 void GrContext::initMockContext() { | 374 void GrContext::initMockContext() { |
377 GrContextOptions options; | 375 GrContextOptions options; |
378 options.fGeometryBufferMapThreshold = 0; | 376 options.fGeometryBufferMapThreshold = 0; |
379 SkASSERT(nullptr == fGpu); | 377 SkASSERT(nullptr == fGpu); |
380 fGpu = new MockGpu(this, options); | 378 fGpu = new MockGpu(this, options); |
381 SkASSERT(fGpu); | 379 SkASSERT(fGpu); |
382 this->initCommon(options); | 380 this->initCommon(options); |
383 | 381 |
384 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 382 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
385 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 383 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
386 // resources in the buffer pools. | 384 // resources in the buffer pools. |
387 fDrawingManager->abandon(); | 385 fDrawingManager->abandon(); |
388 } | 386 } |
OLD | NEW |