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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Code for the mock context. It's built on a mock GrGpu class that does nothing
. | 172 // Code for the mock context. It's built on a mock GrGpu class that does nothing
. |
173 //// | 173 //// |
174 | 174 |
175 #include "GrGpu.h" | 175 #include "GrGpu.h" |
176 | 176 |
177 class GrPipeline; | 177 class GrPipeline; |
178 | 178 |
179 class MockGpu : public GrGpu { | 179 class MockGpu : public GrGpu { |
180 public: | 180 public: |
181 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { | 181 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { |
182 fCaps.reset(SkNEW_ARGS(GrCaps, (options))); | 182 fCaps.reset(new GrCaps(options)); |
183 } | 183 } |
184 ~MockGpu() override {} | 184 ~MockGpu() override {} |
185 | 185 |
186 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 186 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
187 GrPixelConfig readConfig, DrawPreference*, | 187 GrPixelConfig readConfig, DrawPreference*, |
188 ReadPixelTempDrawInfo*) override { return false; } | 188 ReadPixelTempDrawInfo*) override { return false; } |
189 | 189 |
190 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, size
_t rowBytes, | 190 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, size
_t rowBytes, |
191 GrPixelConfig srcConfig, DrawPreference*, | 191 GrPixelConfig srcConfig, DrawPreference*, |
192 WritePixelTempDrawInfo*) override { return false;
} | 192 WritePixelTempDrawInfo*) override { return false;
} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 GrPixelConfig config) const
override { | 274 GrPixelConfig config) const
override { |
275 return 0; | 275 return 0; |
276 } | 276 } |
277 bool isTestingOnlyBackendTexture(GrBackendObject id) const override { return
false; } | 277 bool isTestingOnlyBackendTexture(GrBackendObject id) const override { return
false; } |
278 void deleteTestingOnlyBackendTexture(GrBackendObject id) const override {} | 278 void deleteTestingOnlyBackendTexture(GrBackendObject id) const override {} |
279 | 279 |
280 typedef GrGpu INHERITED; | 280 typedef GrGpu INHERITED; |
281 }; | 281 }; |
282 | 282 |
283 GrContext* GrContext::CreateMockContext() { | 283 GrContext* GrContext::CreateMockContext() { |
284 GrContext* context = SkNEW(GrContext); | 284 GrContext* context = new GrContext; |
285 | 285 |
286 context->initMockContext(); | 286 context->initMockContext(); |
287 return context; | 287 return context; |
288 } | 288 } |
289 | 289 |
290 void GrContext::initMockContext() { | 290 void GrContext::initMockContext() { |
291 GrContextOptions options; | 291 GrContextOptions options; |
292 options.fGeometryBufferMapThreshold = 0; | 292 options.fGeometryBufferMapThreshold = 0; |
293 SkASSERT(NULL == fGpu); | 293 SkASSERT(NULL == fGpu); |
294 fGpu = SkNEW_ARGS(MockGpu, (this, options)); | 294 fGpu = new MockGpu(this, options); |
295 SkASSERT(fGpu); | 295 SkASSERT(fGpu); |
296 this->initCommon(); | 296 this->initCommon(); |
297 | 297 |
298 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 298 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
299 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 299 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
300 // resources in the buffer pools. | 300 // resources in the buffer pools. |
301 fDrawingMgr.abandon(); | 301 fDrawingMgr.abandon(); |
302 } | 302 } |
OLD | NEW |