Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/gpu/GrTest.cpp

Issue 704563004: Revert of Add mock context and use in ResourceCacheTest. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 33
34 /////////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////////
35 35
36 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { 36 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) {
37 fMaxTextureSizeOverride = maxTextureSizeOverride; 37 fMaxTextureSizeOverride = maxTextureSizeOverride;
38 } 38 }
39 39
40 void GrContext::purgeAllUnlockedResources() { 40 void GrContext::purgeAllUnlockedResources() {
41 fResourceCache->purgeAllUnlocked(); 41 fResourceCache->purgeAllUnlocked();
42 } 42 }
43
44 ///////////////////////////////////////////////////////////////////////////////
45 // Code for the mock context. It's built on a mock GrGpu class that does nothing .
46 ////
47
48 #include "GrBufferAllocPool.h"
49 #include "GrInOrderDrawBuffer.h"
50 #include "GrGpu.h"
51
52 class MockGpu : public GrGpu {
53 public:
54 MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrDrawT argetCaps)); }
55 virtual ~MockGpu() { }
56 virtual bool canWriteTexturePixels(const GrTexture*,
57 GrPixelConfig srcConfig) const SK_OVERRID E {
58 return true;
59 }
60
61 virtual bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget,
62 int left, int top,
63 int width, int height,
64 GrPixelConfig config,
65 size_t rowBytes) const SK_OVERRIDE { return false; }
66 virtual void buildProgramDesc(const GrOptDrawState&,
67 const GrProgramDesc::DescInfo&,
68 GrGpu::DrawType,
69 const GrDeviceCoordTexture* dstCopy,
70 GrProgramDesc* desc) SK_OVERRIDE { }
71
72 virtual void discard(GrRenderTarget*) SK_OVERRIDE { }
73
74 private:
75 virtual void onResetContext(uint32_t resetBits) { };
76 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
77 const void* srcData,
78 size_t rowBytes) SK_OVERRIDE {
79 return NULL;
80 }
81
82 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
83 const void* srcData) SK_OVERRI DE {
84 return NULL;
85 }
86
87 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVE RRIDE {
88 return NULL;
89 }
90
91 virtual GrRenderTarget* onWrapBackendRenderTarget(
92 const GrBackendRenderTargetDesc&) SK_OVERRID E {
93 return NULL;
94 }
95
96 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_ OVERRIDE {
97 return NULL;
98 }
99
100 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OV ERRIDE {
101 return NULL;
102 }
103
104 virtual void onGpuClear(GrRenderTarget*, const SkIRect* rect, GrColor color,
105 bool canIgnoreRect) SK_OVERRIDE { }
106
107 virtual void onClearStencilClip(GrRenderTarget*,
108 const SkIRect& rect,
109 bool insideClip) SK_OVERRIDE { }
110
111 virtual void onGpuDraw(const DrawInfo&) SK_ OVERRIDE { }
112 virtual bool onReadPixels(GrRenderTarget* target,
113 int left, int top, int width, int height,
114 GrPixelConfig,
115 void* buffer,
116 size_t rowBytes) SK_OVERRIDE {
117 return false;
118 }
119
120 virtual bool onWriteTexturePixels(GrTexture* texture,
121 int left, int top, int width, int height,
122 GrPixelConfig config, const void* buffer,
123 size_t rowBytes) SK_OVERRIDE {
124 return false;
125 }
126
127 virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE {
128 return;
129 }
130
131 virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width,
132 int height) SK_OVERRIDE {
133 return false;
134 }
135
136 virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTar get*) SK_OVERRIDE {
137 return false;
138 }
139
140 virtual bool flushGraphicsState(DrawType,
141 const GrClipMaskManager::ScissorState&,
142 const GrDeviceCoordTexture* dstCopy) SK_OVE RRIDE {
143 return false;
144 }
145
146 virtual void clearStencil(GrRenderTarget* target) SK_OVERRIDE { }
147
148 virtual void didAddGpuTraceMarker() SK_OVERRIDE { }
149 virtual void didRemoveGpuTraceMarker() SK_OVERRIDE { }
150
151 typedef GrGpu INHERITED;
152 };
153
154 GrContext* GrContext::CreateMockContext() {
155 GrContext* context = SkNEW_ARGS(GrContext, (Options()));
156
157 context->initMockContext();
158 return context;
159 }
160
161 void GrContext::initMockContext() {
162 SkASSERT(NULL == fGpu);
163 fGpu = SkNEW_ARGS(MockGpu, (this));
164 SkASSERT(fGpu);
165 this->initCommon();
166
167 // We delete these because we want to test the cache starting with zero reso urces. Also, none of
168 // these objects are required for any of tests that use this context. TODO: make stop allocating
169 // resources in the buffer pools.
170 SkDELETE(fDrawBuffer);
171 SkDELETE(fDrawBufferVBAllocPool);
172 SkDELETE(fDrawBufferIBAllocPool);
173
174 fDrawBuffer = NULL;
175 fDrawBufferVBAllocPool = NULL;
176 fDrawBufferIBAllocPool = NULL;
177 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698