| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 public: | 181 public: |
| 183 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { | 182 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { |
| 184 fCaps.reset(new GrCaps(options)); | 183 fCaps.reset(new GrCaps(options)); |
| 185 } | 184 } |
| 186 ~MockGpu() override {} | 185 ~MockGpu() override {} |
| 187 | 186 |
| 188 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 187 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
| 189 GrPixelConfig readConfig, DrawPreference*, | 188 GrPixelConfig readConfig, DrawPreference*, |
| 190 ReadPixelTempDrawInfo*) override { return false; } | 189 ReadPixelTempDrawInfo*) override { return false; } |
| 191 | 190 |
| 192 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, size
_t rowBytes, | 191 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| 193 GrPixelConfig srcConfig, DrawPreference*, | 192 GrPixelConfig srcConfig, DrawPreference*, |
| 194 WritePixelTempDrawInfo*) override { return false;
} | 193 WritePixelTempDrawInfo*) override { return false;
} |
| 195 | 194 |
| 196 void buildProgramDesc(GrProgramDesc*, const GrPrimitiveProcessor&, | 195 void buildProgramDesc(GrProgramDesc*, const GrPrimitiveProcessor&, |
| 197 const GrPipeline&) const override {} | 196 const GrPipeline&) const override {} |
| 198 | 197 |
| 199 void discard(GrRenderTarget*) override {} | 198 void discard(GrRenderTarget*) override {} |
| 200 | 199 |
| 201 bool onCopySurface(GrSurface* dst, | 200 bool onCopySurface(GrSurface* dst, |
| 202 GrSurface* src, | 201 GrSurface* src, |
| 203 const SkIRect& srcRect, | 202 const SkIRect& srcRect, |
| 204 const SkIPoint& dstPoint) override { return false; }; | 203 const SkIPoint& dstPoint) override { return false; }; |
| 205 | 204 |
| 206 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override { | 205 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override { |
| 207 return false; | 206 return false; |
| 208 } | 207 } |
| 209 | 208 |
| 210 private: | 209 private: |
| 211 void onResetContext(uint32_t resetBits) override {} | 210 void onResetContext(uint32_t resetBits) override {} |
| 212 | 211 |
| 213 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} | 212 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} |
| 214 | 213 |
| 215 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 214 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
| 216 const void* srcData, size_t rowBytes) override { | 215 const SkTArray<SkMipMapLevel>& texels) override { |
| 217 return nullptr; | 216 return nullptr; |
| 218 } | 217 } |
| 219 | 218 |
| 220 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, | 219 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, |
| 221 const void* srcData) override { | 220 const SkTArray<SkMipMapLevel>& texels)
override { |
| 222 return nullptr; | 221 return nullptr; |
| 223 } | 222 } |
| 224 | 223 |
| 225 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, | 224 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, |
| 226 GrWrapOwnership) override { return nullptr;
} | 225 GrWrapOwnership) override { return nullptr;
} |
| 227 | 226 |
| 228 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 227 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 229 GrWrapOwnership) override { | 228 GrWrapOwnership) override { |
| 230 return nullptr; | 229 return nullptr; |
| 231 } | 230 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 243 bool onReadPixels(GrSurface* surface, | 242 bool onReadPixels(GrSurface* surface, |
| 244 int left, int top, int width, int height, | 243 int left, int top, int width, int height, |
| 245 GrPixelConfig, | 244 GrPixelConfig, |
| 246 void* buffer, | 245 void* buffer, |
| 247 size_t rowBytes) override { | 246 size_t rowBytes) override { |
| 248 return false; | 247 return false; |
| 249 } | 248 } |
| 250 | 249 |
| 251 bool onWritePixels(GrSurface* surface, | 250 bool onWritePixels(GrSurface* surface, |
| 252 int left, int top, int width, int height, | 251 int left, int top, int width, int height, |
| 253 GrPixelConfig config, const void* buffer, | 252 GrPixelConfig config, const SkTArray<SkMipMapLevel>& texe
ls) override { |
| 254 size_t rowBytes) override { | |
| 255 return false; | 253 return false; |
| 256 } | 254 } |
| 257 | 255 |
| 258 void onResolveRenderTarget(GrRenderTarget* target) override { return; } | 256 void onResolveRenderTarget(GrRenderTarget* target) override { return; } |
| 259 | 257 |
| 260 GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTa
rget*, | 258 GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTa
rget*, |
| 261 int width, | 259 int width, |
| 262 int height) over
ride { | 260 int height) over
ride { |
| 263 return nullptr; | 261 return nullptr; |
| 264 } | 262 } |
| 265 | 263 |
| 266 void clearStencil(GrRenderTarget* target) override {} | 264 void clearStencil(GrRenderTarget* target) override {} |
| 267 | 265 |
| 268 GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, | 266 GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, |
| 269 GrPixelConfig config) const
override { | 267 GrPixelConfig config) const
override { |
| 270 return 0; | 268 return 0; |
| 271 } | 269 } |
| 272 bool isTestingOnlyBackendTexture(GrBackendObject id) const override { return
false; } | 270 bool isTestingOnlyBackendTexture(GrBackendObject id) const override { return
false; } |
| 273 void deleteTestingOnlyBackendTexture(GrBackendObject id) const override {} | 271 void deleteTestingOnlyBackendTexture(GrBackendObject id) const override {} |
| 274 | 272 |
| 275 typedef GrGpu INHERITED; | 273 typedef GrGpu INHERITED; |
| 276 }; | 274 }; |
| 277 | 275 |
| 278 GrContext* GrContext::CreateMockContext() { | 276 GrContext* GrContext::CreateMockContext() { |
| 279 GrContext* context = new GrContext; | 277 GrContext* context = new GrContext; |
| 280 | 278 |
| 281 context->initMockContext(); | 279 context->initMockContext(); |
| 282 return context; | 280 return context; |
| 283 } | 281 } |
| 284 | 282 |
| 285 void GrContext::initMockContext() { | 283 void GrContext::initMockContext() { |
| 286 GrContextOptions options; | 284 GrContextOptions options; |
| 287 options.fGeometryBufferMapThreshold = 0; | 285 options.fGeometryBufferMapThreshold = 0; |
| 288 SkASSERT(nullptr == fGpu); | 286 SkASSERT(nullptr == fGpu); |
| 289 fGpu = new MockGpu(this, options); | 287 fGpu = new MockGpu(this, options); |
| 290 SkASSERT(fGpu); | 288 SkASSERT(fGpu); |
| 291 this->initCommon(options); | 289 this->initCommon(options); |
| 292 | 290 |
| 293 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 291 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
| 294 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 292 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
| 295 // resources in the buffer pools. | 293 // resources in the buffer pools. |
| 296 fDrawingManager->abandon(); | 294 fDrawingManager->abandon(); |
| 297 } | 295 } |
| OLD | NEW |