| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 public: | 289 public: |
| 291 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { | 290 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { |
| 292 fCaps.reset(new MockCaps(options)); | 291 fCaps.reset(new MockCaps(options)); |
| 293 } | 292 } |
| 294 ~MockGpu() override {} | 293 ~MockGpu() override {} |
| 295 | 294 |
| 296 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 295 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
| 297 GrPixelConfig readConfig, DrawPreference*, | 296 GrPixelConfig readConfig, DrawPreference*, |
| 298 ReadPixelTempDrawInfo*) override { return false; } | 297 ReadPixelTempDrawInfo*) override { return false; } |
| 299 | 298 |
| 300 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, size
_t rowBytes, | 299 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| 301 GrPixelConfig srcConfig, DrawPreference*, | 300 GrPixelConfig srcConfig, DrawPreference*, |
| 302 WritePixelTempDrawInfo*) override { return false;
} | 301 WritePixelTempDrawInfo*) override { return false;
} |
| 303 | 302 |
| 304 void buildProgramDesc(GrProgramDesc*, const GrPrimitiveProcessor&, | 303 void buildProgramDesc(GrProgramDesc*, const GrPrimitiveProcessor&, |
| 305 const GrPipeline&) const override {} | 304 const GrPipeline&) const override {} |
| 306 | 305 |
| 307 void discard(GrRenderTarget*) override {} | 306 void discard(GrRenderTarget*) override {} |
| 308 | 307 |
| 309 bool onCopySurface(GrSurface* dst, | 308 bool onCopySurface(GrSurface* dst, |
| 310 GrSurface* src, | 309 GrSurface* src, |
| 311 const SkIRect& srcRect, | 310 const SkIRect& srcRect, |
| 312 const SkIPoint& dstPoint) override { return false; }; | 311 const SkIPoint& dstPoint) override { return false; }; |
| 313 | 312 |
| 314 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override { | 313 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override { |
| 315 return false; | 314 return false; |
| 316 } | 315 } |
| 317 | 316 |
| 318 void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) override {}
; | 317 void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) override {}
; |
| 319 | 318 |
| 320 private: | 319 private: |
| 321 void onResetContext(uint32_t resetBits) override {} | 320 void onResetContext(uint32_t resetBits) override {} |
| 322 | 321 |
| 323 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} | 322 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} |
| 324 | 323 |
| 325 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 324 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
| 326 const void* srcData, size_t rowBytes) override { | 325 const SkTArray<SkMipMapLevel>& texels) override { |
| 327 return nullptr; | 326 return nullptr; |
| 328 } | 327 } |
| 329 | 328 |
| 330 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, | 329 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, |
| 331 const void* srcData) override { | 330 const SkTArray<SkMipMapLevel>& texels)
override { |
| 332 return nullptr; | 331 return nullptr; |
| 333 } | 332 } |
| 334 | 333 |
| 335 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, | 334 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, |
| 336 GrWrapOwnership) override { return nullptr;
} | 335 GrWrapOwnership) override { return nullptr;
} |
| 337 | 336 |
| 338 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 337 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 339 GrWrapOwnership) override { | 338 GrWrapOwnership) override { |
| 340 return nullptr; | 339 return nullptr; |
| 341 } | 340 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 355 bool onReadPixels(GrSurface* surface, | 354 bool onReadPixels(GrSurface* surface, |
| 356 int left, int top, int width, int height, | 355 int left, int top, int width, int height, |
| 357 GrPixelConfig, | 356 GrPixelConfig, |
| 358 void* buffer, | 357 void* buffer, |
| 359 size_t rowBytes) override { | 358 size_t rowBytes) override { |
| 360 return false; | 359 return false; |
| 361 } | 360 } |
| 362 | 361 |
| 363 bool onWritePixels(GrSurface* surface, | 362 bool onWritePixels(GrSurface* surface, |
| 364 int left, int top, int width, int height, | 363 int left, int top, int width, int height, |
| 365 GrPixelConfig config, const void* buffer, | 364 GrPixelConfig config, const SkTArray<SkMipMapLevel>& texe
ls) override { |
| 366 size_t rowBytes) override { | |
| 367 return false; | 365 return false; |
| 368 } | 366 } |
| 369 | 367 |
| 370 bool onTransferPixels(GrSurface* surface, | 368 bool onTransferPixels(GrSurface* surface, |
| 371 int left, int top, int width, int height, | 369 int left, int top, int width, int height, |
| 372 GrPixelConfig config, GrTransferBuffer* buffer, | 370 GrPixelConfig config, GrTransferBuffer* buffer, |
| 373 size_t offset, size_t rowBytes) override { | 371 size_t offset, size_t rowBytes) override { |
| 374 return false; | 372 return false; |
| 375 } | 373 } |
| 376 | 374 |
| 377 void onResolveRenderTarget(GrRenderTarget* target) override { return; } | 375 void onResolveRenderTarget(GrRenderTarget* target) override { return; } |
| 378 | 376 |
| 379 GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTa
rget*, | 377 GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTa
rget*, |
| 380 int width, | 378 int width, |
| 381 int height) over
ride { | 379 int height) over
ride { |
| 382 return nullptr; | 380 return nullptr; |
| 383 } | 381 } |
| 384 | 382 |
| 385 void clearStencil(GrRenderTarget* target) override {} | 383 void clearStencil(GrRenderTarget* target) override {} |
| 386 | 384 |
| 387 GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, | 385 GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, |
| 388 GrPixelConfig config) const
override { | 386 GrPixelConfig config) const
override { |
| 389 return 0; | 387 return 0; |
| 390 } | 388 } |
| 391 bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return f
alse; } | 389 bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return f
alse; } |
| 392 void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) c
onst override {} | 390 void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) c
onst override {} |
| 393 | 391 |
| 394 typedef GrGpu INHERITED; | 392 typedef GrGpu INHERITED; |
| 395 }; | 393 }; |
| 396 | 394 |
| 397 GrContext* GrContext::CreateMockContext() { | 395 GrContext* GrContext::CreateMockContext() { |
| 398 GrContext* context = new GrContext; | 396 GrContext* context = new GrContext; |
| 399 | 397 |
| 400 context->initMockContext(); | 398 context->initMockContext(); |
| 401 return context; | 399 return context; |
| 402 } | 400 } |
| 403 | 401 |
| 404 void GrContext::initMockContext() { | 402 void GrContext::initMockContext() { |
| 405 GrContextOptions options; | 403 GrContextOptions options; |
| 406 options.fGeometryBufferMapThreshold = 0; | 404 options.fGeometryBufferMapThreshold = 0; |
| 407 SkASSERT(nullptr == fGpu); | 405 SkASSERT(nullptr == fGpu); |
| 408 fGpu = new MockGpu(this, options); | 406 fGpu = new MockGpu(this, options); |
| 409 SkASSERT(fGpu); | 407 SkASSERT(fGpu); |
| 410 this->initCommon(options); | 408 this->initCommon(options); |
| 411 | 409 |
| 412 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 410 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
| 413 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 411 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
| 414 // resources in the buffer pools. | 412 // resources in the buffer pools. |
| 415 fDrawingManager->abandon(); | 413 fDrawingManager->abandon(); |
| 416 } | 414 } |
| OLD | NEW |