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 #include "GrContextOptions.h" |
10 | 11 |
11 #include "GrGpuResourceCacheAccess.h" | 12 #include "GrGpuResourceCacheAccess.h" |
12 #include "GrInOrderDrawBuffer.h" | 13 #include "GrInOrderDrawBuffer.h" |
13 #include "GrResourceCache.h" | 14 #include "GrResourceCache.h" |
14 #include "SkString.h" | 15 #include "SkString.h" |
15 | 16 |
16 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { | 17 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { |
17 SkASSERT(!fContext); | 18 SkASSERT(!fContext); |
18 | 19 |
19 fContext.reset(SkRef(ctx)); | 20 fContext.reset(SkRef(ctx)); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // Code for the mock context. It's built on a mock GrGpu class that does nothing
. | 132 // Code for the mock context. It's built on a mock GrGpu class that does nothing
. |
132 //// | 133 //// |
133 | 134 |
134 #include "GrInOrderDrawBuffer.h" | 135 #include "GrInOrderDrawBuffer.h" |
135 #include "GrGpu.h" | 136 #include "GrGpu.h" |
136 | 137 |
137 class GrPipeline; | 138 class GrPipeline; |
138 | 139 |
139 class MockGpu : public GrGpu { | 140 class MockGpu : public GrGpu { |
140 public: | 141 public: |
141 MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrCaps)
); } | 142 MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(con
text) { |
| 143 fCaps.reset(SkNEW_ARGS(GrCaps, (options))); |
| 144 } |
142 ~MockGpu() override {} | 145 ~MockGpu() override {} |
143 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
override { | 146 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
override { |
144 return true; | 147 return true; |
145 } | 148 } |
146 | 149 |
147 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, | 150 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
148 int left, int top, | 151 int left, int top, |
149 int width, int height, | 152 int width, int height, |
150 GrPixelConfig config, | 153 GrPixelConfig config, |
151 size_t rowBytes) const override { return fals
e; } | 154 size_t rowBytes) const override { return fals
e; } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 void clearStencil(GrRenderTarget* target) override {} | 245 void clearStencil(GrRenderTarget* target) override {} |
243 | 246 |
244 void didAddGpuTraceMarker() override {} | 247 void didAddGpuTraceMarker() override {} |
245 | 248 |
246 void didRemoveGpuTraceMarker() override {} | 249 void didRemoveGpuTraceMarker() override {} |
247 | 250 |
248 typedef GrGpu INHERITED; | 251 typedef GrGpu INHERITED; |
249 }; | 252 }; |
250 | 253 |
251 GrContext* GrContext::CreateMockContext() { | 254 GrContext* GrContext::CreateMockContext() { |
252 GrContext* context = SkNEW_ARGS(GrContext, (Options())); | 255 GrContext* context = SkNEW(GrContext); |
253 | 256 |
254 context->initMockContext(); | 257 context->initMockContext(); |
255 return context; | 258 return context; |
256 } | 259 } |
257 | 260 |
258 void GrContext::initMockContext() { | 261 void GrContext::initMockContext() { |
| 262 GrContextOptions options; |
259 SkASSERT(NULL == fGpu); | 263 SkASSERT(NULL == fGpu); |
260 fGpu = SkNEW_ARGS(MockGpu, (this)); | 264 fGpu = SkNEW_ARGS(MockGpu, (this, options)); |
261 SkASSERT(fGpu); | 265 SkASSERT(fGpu); |
262 this->initCommon(); | 266 this->initCommon(); |
263 | 267 |
264 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 268 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
265 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 269 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
266 // resources in the buffer pools. | 270 // resources in the buffer pools. |
267 SkDELETE(fDrawBuffer); | 271 SkDELETE(fDrawBuffer); |
268 fDrawBuffer = NULL; | 272 fDrawBuffer = NULL; |
269 | 273 |
270 } | 274 } |
OLD | NEW |