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