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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 #include "GrBufferAllocPool.h" | 47 #include "GrBufferAllocPool.h" |
48 #include "GrInOrderDrawBuffer.h" | 48 #include "GrInOrderDrawBuffer.h" |
49 #include "GrGpu.h" | 49 #include "GrGpu.h" |
50 | 50 |
51 class GrOptDrawState; | 51 class GrOptDrawState; |
52 | 52 |
53 class MockGpu : public GrGpu { | 53 class MockGpu : public GrGpu { |
54 public: | 54 public: |
55 MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrDrawT
argetCaps)); } | 55 MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrDrawT
argetCaps)); } |
56 virtual ~MockGpu() { } | 56 ~MockGpu() SK_OVERRIDE {} |
57 virtual bool canWriteTexturePixels(const GrTexture*, | 57 bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const
SK_OVERRIDE { |
58 GrPixelConfig srcConfig) const SK_OVERRID
E { | |
59 return true; | 58 return true; |
60 } | 59 } |
61 | 60 |
62 virtual bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, | 61 bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
63 int left, int top, | 62 int left, int top, |
64 int width, int height, | 63 int width, int height, |
65 GrPixelConfig config, | 64 GrPixelConfig config, |
66 size_t rowBytes) const SK_OVERRIDE {
return false; } | 65 size_t rowBytes) const SK_OVERRIDE { return f
alse; } |
67 virtual void buildProgramDesc(const GrOptDrawState&, | 66 void buildProgramDesc(const GrOptDrawState&, |
68 const GrProgramDesc::DescInfo&, | 67 const GrProgramDesc::DescInfo&, |
69 GrGpu::DrawType, | 68 GrGpu::DrawType, |
70 GrProgramDesc* desc) SK_OVERRIDE { } | 69 GrProgramDesc* desc) SK_OVERRIDE {} |
71 | 70 |
72 virtual void discard(GrRenderTarget*) SK_OVERRIDE { } | 71 void discard(GrRenderTarget*) SK_OVERRIDE {} |
73 | 72 |
74 virtual bool canCopySurface(const GrSurface* dst, | 73 bool canCopySurface(const GrSurface* dst, |
75 const GrSurface* src, | 74 const GrSurface* src, |
76 const SkIRect& srcRect, | 75 const SkIRect& srcRect, |
77 const SkIPoint& dstPoint) SK_OVERRIDE { return f
alse; }; | 76 const SkIPoint& dstPoint) SK_OVERRIDE { return false; }; |
78 | 77 |
79 virtual bool copySurface(GrSurface* dst, | 78 bool copySurface(GrSurface* dst, |
80 GrSurface* src, | 79 GrSurface* src, |
81 const SkIRect& srcRect, | 80 const SkIRect& srcRect, |
82 const SkIPoint& dstPoint) SK_OVERRIDE { return fals
e; }; | 81 const SkIPoint& dstPoint) SK_OVERRIDE { return false; }; |
| 82 |
| 83 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OV
ERRIDE { |
| 84 return false; |
| 85 } |
83 | 86 |
84 private: | 87 private: |
85 virtual void onResetContext(uint32_t resetBits) { }; | 88 void onResetContext(uint32_t resetBits) SK_OVERRIDE {} |
86 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, | 89 |
87 const void* srcData, | 90 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, |
88 size_t rowBytes) SK_OVERRIDE { | 91 const void* srcData, |
| 92 size_t rowBytes) SK_OVERRIDE { |
89 return NULL; | 93 return NULL; |
90 } | 94 } |
91 | 95 |
92 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 96 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
93 const void* srcData) SK_OVERRI
DE { | 97 const void* srcData) SK_OVERRIDE { |
94 return NULL; | 98 return NULL; |
95 } | 99 } |
96 | 100 |
97 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVE
RRIDE { | 101 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE { r
eturn NULL; } |
| 102 |
| 103 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
SK_OVERRIDE { |
98 return NULL; | 104 return NULL; |
99 } | 105 } |
100 | 106 |
101 virtual GrRenderTarget* onWrapBackendRenderTarget( | 107 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE
{ return NULL; } |
102 const GrBackendRenderTargetDesc&) SK_OVERRID
E { | |
103 return NULL; | |
104 } | |
105 | 108 |
106 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_
OVERRIDE { | 109 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE {
return NULL; } |
107 return NULL; | |
108 } | |
109 | 110 |
110 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OV
ERRIDE { | 111 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
111 return NULL; | 112 bool canIgnoreRect) SK_OVERRIDE {} |
112 } | |
113 | 113 |
114 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 114 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) SK_OVERRIDE {} |
115 bool canIgnoreRect) SK_OVERRIDE { } | |
116 | 115 |
117 virtual void onClearStencilClip(GrRenderTarget*, | 116 void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) SK_OVERRID
E {} |
118 const SkIRect& rect, | |
119 bool insideClip) SK_OVERRIDE { } | |
120 | 117 |
121 virtual void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) S
K_OVERRIDE { } | 118 bool onReadPixels(GrRenderTarget* target, |
122 virtual bool onReadPixels(GrRenderTarget* target, | 119 int left, int top, int width, int height, |
123 int left, int top, int width, int height, | 120 GrPixelConfig, |
124 GrPixelConfig, | 121 void* buffer, |
125 void* buffer, | 122 size_t rowBytes) SK_OVERRIDE { |
126 size_t rowBytes) SK_OVERRIDE { | |
127 return false; | 123 return false; |
128 } | 124 } |
129 | 125 |
130 virtual bool onWriteTexturePixels(GrTexture* texture, | 126 bool onWriteTexturePixels(GrTexture* texture, |
131 int left, int top, int width, int height, | 127 int left, int top, int width, int height, |
132 GrPixelConfig config, const void* buffer, | 128 GrPixelConfig config, const void* buffer, |
133 size_t rowBytes) SK_OVERRIDE { | 129 size_t rowBytes) SK_OVERRIDE { |
134 return false; | 130 return false; |
135 } | 131 } |
136 | 132 |
137 virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE { | 133 void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE { return; } |
138 return; | |
139 } | |
140 | 134 |
141 virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, | 135 bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, int heig
ht) SK_OVERRIDE { |
142 int height) SK_OVERRIDE { | |
143 return false; | 136 return false; |
144 } | 137 } |
145 | 138 |
146 virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTar
get*) SK_OVERRIDE { | 139 bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTarget*) SK
_OVERRIDE { |
147 return false; | 140 return false; |
148 } | 141 } |
149 | 142 |
150 virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRID
E { | 143 bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRIDE { retur
n false; } |
151 return false; | |
152 } | |
153 | 144 |
154 virtual void clearStencil(GrRenderTarget* target) SK_OVERRIDE { } | 145 void clearStencil(GrRenderTarget* target) SK_OVERRIDE {} |
155 | 146 |
156 virtual void didAddGpuTraceMarker() SK_OVERRIDE { } | 147 void didAddGpuTraceMarker() SK_OVERRIDE { } |
157 virtual void didRemoveGpuTraceMarker() SK_OVERRIDE { } | 148 |
| 149 void didRemoveGpuTraceMarker() SK_OVERRIDE { } |
158 | 150 |
159 typedef GrGpu INHERITED; | 151 typedef GrGpu INHERITED; |
160 }; | 152 }; |
161 | 153 |
162 GrContext* GrContext::CreateMockContext() { | 154 GrContext* GrContext::CreateMockContext() { |
163 GrContext* context = SkNEW_ARGS(GrContext, (Options())); | 155 GrContext* context = SkNEW_ARGS(GrContext, (Options())); |
164 | 156 |
165 context->initMockContext(); | 157 context->initMockContext(); |
166 return context; | 158 return context; |
167 } | 159 } |
168 | 160 |
169 void GrContext::initMockContext() { | 161 void GrContext::initMockContext() { |
170 SkASSERT(NULL == fGpu); | 162 SkASSERT(NULL == fGpu); |
171 fGpu = SkNEW_ARGS(MockGpu, (this)); | 163 fGpu = SkNEW_ARGS(MockGpu, (this)); |
172 SkASSERT(fGpu); | 164 SkASSERT(fGpu); |
173 this->initCommon(); | 165 this->initCommon(); |
174 | 166 |
175 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 167 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
176 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 168 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
177 // resources in the buffer pools. | 169 // resources in the buffer pools. |
178 SkDELETE(fDrawBuffer); | 170 SkDELETE(fDrawBuffer); |
179 SkDELETE(fDrawBufferVBAllocPool); | 171 SkDELETE(fDrawBufferVBAllocPool); |
180 SkDELETE(fDrawBufferIBAllocPool); | 172 SkDELETE(fDrawBufferIBAllocPool); |
181 | 173 |
182 fDrawBuffer = NULL; | 174 fDrawBuffer = NULL; |
183 fDrawBufferVBAllocPool = NULL; | 175 fDrawBufferVBAllocPool = NULL; |
184 fDrawBufferIBAllocPool = NULL; | 176 fDrawBufferIBAllocPool = NULL; |
185 } | 177 } |
OLD | NEW |