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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 12843026: Make GrDrawTarget::Caps ref counted and GrGLCaps derive from it. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 return status == GR_GL_FRAMEBUFFER_COMPLETE; 147 return status == GR_GL_FRAMEBUFFER_COMPLETE;
148 } 148 }
149 149
150 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) 150 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
151 : GrGpu(context) 151 : GrGpu(context)
152 , fGLContext(ctx) { 152 , fGLContext(ctx) {
153 153
154 GrAssert(ctx.isInitialized()); 154 GrAssert(ctx.isInitialized());
155 155
156 fCaps.reset(SkRef(ctx.info().caps()));
157
156 fillInConfigRenderableTable(); 158 fillInConfigRenderableTable();
157 159
158 fPrintedCaps = false;
159 160
160 GrGLClearErr(fGLContext.interface()); 161 GrGLClearErr(fGLContext.interface());
161 162
162 if (gPrintStartupSpew) { 163 if (gPrintStartupSpew) {
163 const GrGLubyte* ext; 164 const GrGLubyte* ext;
164 GL_CALL_RET(ext, GetString(GR_GL_EXTENSIONS)); 165 GL_CALL_RET(ext, GetString(GR_GL_EXTENSIONS));
165 const GrGLubyte* vendor; 166 const GrGLubyte* vendor;
166 const GrGLubyte* renderer; 167 const GrGLubyte* renderer;
167 const GrGLubyte* version; 168 const GrGLubyte* version;
168 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); 169 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR));
169 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); 170 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER));
170 GL_CALL_RET(version, GetString(GR_GL_VERSION)); 171 GL_CALL_RET(version, GetString(GR_GL_VERSION));
171 GrPrintf("------------------------- create GrGpuGL %p --------------\n", 172 GrPrintf("------------------------- create GrGpuGL %p --------------\n",
172 this); 173 this);
173 GrPrintf("------ VENDOR %s\n", vendor); 174 GrPrintf("------ VENDOR %s\n", vendor);
174 GrPrintf("------ RENDERER %s\n", renderer); 175 GrPrintf("------ RENDERER %s\n", renderer);
175 GrPrintf("------ VERSION %s\n", version); 176 GrPrintf("------ VERSION %s\n", version);
176 GrPrintf("------ EXTENSIONS\n %s \n", ext); 177 GrPrintf("------ EXTENSIONS\n %s \n", ext);
178 ctx.info().caps()->print();
177 } 179 }
178 180
179 this->initCaps();
180
181 fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext())); 181 fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext()));
182 182
183 GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kVertexAttribC nt); 183 GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kVertexAttribC nt);
184 GrAssert(this->glCaps().maxVertexAttributes() > GrDrawState::kColorOverrideA ttribIndexValue); 184 GrAssert(this->glCaps().maxVertexAttributes() > GrDrawState::kColorOverrideA ttribIndexValue);
185 GrAssert(this->glCaps().maxVertexAttributes() > GrDrawState::kCoverageOverri deAttribIndexValue); 185 GrAssert(this->glCaps().maxVertexAttributes() > GrDrawState::kCoverageOverri deAttribIndexValue);
186 186
187 fLastSuccessfulStencilFmtIdx = 0; 187 fLastSuccessfulStencilFmtIdx = 0;
188 if (false) { // avoid bit rot, suppress warning 188 if (false) { // avoid bit rot, suppress warning
189 fbo_test(this->glInterface(), 0, 0); 189 fbo_test(this->glInterface(), 0, 0);
190 } 190 }
(...skipping 11 matching lines...) Expand all
202 202
203 // This must be called by before the GrDrawTarget destructor 203 // This must be called by before the GrDrawTarget destructor
204 this->releaseGeometry(); 204 this->releaseGeometry();
205 // This subclass must do this before the base class destructor runs 205 // This subclass must do this before the base class destructor runs
206 // since we will unref the GrGLInterface. 206 // since we will unref the GrGLInterface.
207 this->releaseResources(); 207 this->releaseResources();
208 } 208 }
209 209
210 /////////////////////////////////////////////////////////////////////////////// 210 ///////////////////////////////////////////////////////////////////////////////
211 211
212 void GrGpuGL::initCaps() {
213 GrGLint maxTextureUnits;
214 // check FS and fixed-function texture unit limits
215 // we only use textures in the fragment stage currently.
216 // checks are > to make sure we have a spare unit.
217 const GrGLInterface* gl = this->glInterface();
218 GR_GL_GetIntegerv(gl, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
219 GrAssert(maxTextureUnits > GrDrawState::kNumStages);
220
221 CapsInternals* caps = this->capsInternals();
222
223 GrGLint numFormats;
224 GR_GL_GetIntegerv(gl, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
225 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
226 GR_GL_GetIntegerv(gl, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
227 for (int i = 0; i < numFormats; ++i) {
228 if (formats[i] == GR_GL_PALETTE8_RGBA8) {
229 caps->f8BitPaletteSupport = true;
230 break;
231 }
232 }
233
234 if (kDesktop_GrGLBinding == this->glBinding()) {
235 // we could also look for GL_ATI_separate_stencil extension or
236 // GL_EXT_stencil_two_side but they use different function signatures
237 // than GL2.0+ (and than each other).
238 caps->fTwoSidedStencilSupport = (this->glVersion() >= GR_GL_VER(2,0));
239 // supported on GL 1.4 and higher or by extension
240 caps->fStencilWrapOpsSupport = (this->glVersion() >= GR_GL_VER(1,4)) ||
241 this->hasExtension("GL_EXT_stencil_wrap") ;
242 } else {
243 // ES 2 has two sided stencil and stencil wrap
244 caps->fTwoSidedStencilSupport = true;
245 caps->fStencilWrapOpsSupport = true;
246 }
247
248 if (kDesktop_GrGLBinding == this->glBinding()) {
249 caps->fBufferLockSupport = true; // we require VBO support and the deskt op VBO
250 // extension includes glMapBuffer.
251 } else {
252 caps->fBufferLockSupport = this->hasExtension("GL_OES_mapbuffer");
253 }
254
255 if (kDesktop_GrGLBinding == this->glBinding()) {
256 if (this->glVersion() >= GR_GL_VER(2,0) ||
257 this->hasExtension("GL_ARB_texture_non_power_of_two")) {
258 caps->fNPOTTextureTileSupport = true;
259 } else {
260 caps->fNPOTTextureTileSupport = false;
261 }
262 } else {
263 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only
264 caps->fNPOTTextureTileSupport = this->hasExtension("GL_OES_texture_npot" );
265 }
266
267 caps->fHWAALineSupport = (kDesktop_GrGLBinding == this->glBinding());
268
269 GR_GL_GetIntegerv(gl, GR_GL_MAX_TEXTURE_SIZE, &caps->fMaxTextureSize);
270 GR_GL_GetIntegerv(gl, GR_GL_MAX_RENDERBUFFER_SIZE, &caps->fMaxRenderTargetSi ze);
271 // Our render targets are always created with textures as the color
272 // attachment, hence this min:
273 caps->fMaxRenderTargetSize = GrMin(caps->fMaxTextureSize, caps->fMaxRenderTa rgetSize);
274
275 caps->fFSAASupport = GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType() ;
276 caps->fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING &&
277 this->hasExtension("GL_NV_path_rendering");
278
279 // Enable supported shader-related caps
280 if (kDesktop_GrGLBinding == this->glBinding()) {
281 caps->fDualSourceBlendingSupport = this->glVersion() >= GR_GL_VER(3,3) | |
282 this->hasExtension("GL_ARB_blend_func _extended");
283 caps->fShaderDerivativeSupport = true;
284 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
285 caps->fGeometryShaderSupport = this->glVersion() >= GR_GL_VER(3,2) &&
286 this->glslGeneration() >= k150_GrGLSLGene ration;
287 } else {
288 caps->fShaderDerivativeSupport = this->hasExtension("GL_OES_standard_der ivatives");
289 }
290
291 if (GrGLCaps::kImaginationES_MSFBOType == this->glCaps().msFBOType()) {
292 GR_GL_GetIntegerv(this->glInterface(), GR_GL_MAX_SAMPLES_IMG, &caps->fMa xSampleCount);
293 } else if (GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType()) {
294 GR_GL_GetIntegerv(this->glInterface(), GR_GL_MAX_SAMPLES, &caps->fMaxSam pleCount);
295 }
296 }
297
298 void GrGpuGL::fillInConfigRenderableTable() { 212 void GrGpuGL::fillInConfigRenderableTable() {
299 213
300 // OpenGL < 3.0 214 // OpenGL < 3.0
301 // no support for render targets unless the GL_ARB_framebuffer_object 215 // no support for render targets unless the GL_ARB_framebuffer_object
302 // extension is supported (in which case we get ALPHA, RED, RG, RGB, 216 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
303 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we 217 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
304 // probably don't get R8 in this case. 218 // probably don't get R8 in this case.
305 219
306 // OpenGL 3.0 220 // OpenGL 3.0
307 // base color renderable: ALPHA, RED, RG, RGB, and RGBA 221 // base color renderable: ALPHA, RED, RG, RGB, and RGBA
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } else { 306 } else {
393 return true; 307 return true;
394 } 308 }
395 } 309 }
396 310
397 bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const { 311 bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const {
398 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL); 312 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL);
399 } 313 }
400 314
401 void GrGpuGL::onResetContext() { 315 void GrGpuGL::onResetContext() {
402 if (gPrintStartupSpew && !fPrintedCaps) {
403 fPrintedCaps = true;
404 this->getCaps().print();
405 this->glCaps().print();
406 }
407 316
408 // we don't use the zb at all 317 // we don't use the zb at all
409 GL_CALL(Disable(GR_GL_DEPTH_TEST)); 318 GL_CALL(Disable(GR_GL_DEPTH_TEST));
410 GL_CALL(DepthMask(GR_GL_FALSE)); 319 GL_CALL(DepthMask(GR_GL_FALSE));
411 320
412 fHWDrawFace = GrDrawState::kInvalid_DrawFace; 321 fHWDrawFace = GrDrawState::kInvalid_DrawFace;
413 fHWDitherEnabled = kUnknown_TriState; 322 fHWDitherEnabled = kUnknown_TriState;
414 323
415 if (kDesktop_GrGLBinding == this->glBinding()) { 324 if (kDesktop_GrGLBinding == this->glBinding()) {
416 // Desktop-only state that we never change 325 // Desktop-only state that we never change
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 fHWViewport.invalidate(); 365 fHWViewport.invalidate();
457 366
458 fHWStencilSettings.invalidate(); 367 fHWStencilSettings.invalidate();
459 fHWStencilTestEnabled = kUnknown_TriState; 368 fHWStencilTestEnabled = kUnknown_TriState;
460 369
461 fHWGeometryState.invalidate(); 370 fHWGeometryState.invalidate();
462 371
463 fHWBoundRenderTarget = NULL; 372 fHWBoundRenderTarget = NULL;
464 373
465 fHWPathStencilMatrixState.invalidate(); 374 fHWPathStencilMatrixState.invalidate();
466 if (fCaps.pathStencilingSupport()) { 375 if (this->caps()->pathStencilingSupport()) {
467 // we don't use the model view matrix. 376 // we don't use the model view matrix.
468 GL_CALL(MatrixMode(GR_GL_MODELVIEW)); 377 GL_CALL(MatrixMode(GR_GL_MODELVIEW));
469 GL_CALL(LoadIdentity()); 378 GL_CALL(LoadIdentity());
470 } 379 }
471 380
472 // we assume these values 381 // we assume these values
473 if (this->glCaps().unpackRowLengthSupport()) { 382 if (this->glCaps().unpackRowLengthSupport()) {
474 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); 383 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
475 } 384 }
476 if (this->glCaps().packRowLengthSupport()) { 385 if (this->glCaps().packRowLengthSupport()) {
(...skipping 27 matching lines...) Expand all
504 413
505 GrTexture* GrGpuGL::onWrapBackendTexture(const GrBackendTextureDesc& desc) { 414 GrTexture* GrGpuGL::onWrapBackendTexture(const GrBackendTextureDesc& desc) {
506 if (!this->configToGLFormats(desc.fConfig, false, NULL, NULL, NULL)) { 415 if (!this->configToGLFormats(desc.fConfig, false, NULL, NULL, NULL)) {
507 return NULL; 416 return NULL;
508 } 417 }
509 418
510 if (0 == desc.fTextureHandle) { 419 if (0 == desc.fTextureHandle) {
511 return NULL; 420 return NULL;
512 } 421 }
513 422
514 int maxSize = this->getCaps().maxTextureSize(); 423 int maxSize = this->caps()->maxTextureSize();
515 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { 424 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
516 return NULL; 425 return NULL;
517 } 426 }
518 427
519 GrGLTexture::Desc glTexDesc; 428 GrGLTexture::Desc glTexDesc;
520 // next line relies on GrBackendTextureDesc's flags matching GrTexture's 429 // next line relies on GrBackendTextureDesc's flags matching GrTexture's
521 glTexDesc.fFlags = (GrTextureFlags) desc.fFlags; 430 glTexDesc.fFlags = (GrTextureFlags) desc.fFlags;
522 glTexDesc.fWidth = desc.fWidth; 431 glTexDesc.fWidth = desc.fWidth;
523 glTexDesc.fHeight = desc.fHeight; 432 glTexDesc.fHeight = desc.fHeight;
524 glTexDesc.fConfig = desc.fConfig; 433 glTexDesc.fConfig = desc.fConfig;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 738 }
830 return succeeded; 739 return succeeded;
831 } 740 }
832 741
833 namespace { 742 namespace {
834 bool renderbuffer_storage_msaa(GrGLContext& ctx, 743 bool renderbuffer_storage_msaa(GrGLContext& ctx,
835 int sampleCount, 744 int sampleCount,
836 GrGLenum format, 745 GrGLenum format,
837 int width, int height) { 746 int width, int height) {
838 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); 747 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
839 GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps().msFBOType()); 748 GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps()->msFBOType());
840 bool created = false; 749 bool created = false;
841 if (GrGLCaps::kNVDesktop_CoverageAAType == 750 if (GrGLCaps::kNVDesktop_CoverageAAType ==
842 ctx.info().caps().coverageAAType()) { 751 ctx.info().caps()->coverageAAType()) {
843 const GrGLCaps::MSAACoverageMode& mode = 752 const GrGLCaps::MSAACoverageMode& mode =
844 ctx.info().caps().getMSAACoverageMode(sampleCount); 753 ctx.info().caps()->getMSAACoverageMode(sampleCount);
845 GL_ALLOC_CALL(ctx.interface(), 754 GL_ALLOC_CALL(ctx.interface(),
846 RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER, 755 RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER,
847 mode.fCoverageSampleCnt, 756 mode.fCoverageSampleCnt,
848 mode.fColorSampleCnt, 757 mode.fColorSampleCnt,
849 format, 758 format,
850 width, height)); 759 width, height));
851 created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); 760 created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
852 } 761 }
853 if (!created) { 762 if (!created) {
854 GL_ALLOC_CALL(ctx.interface(), 763 GL_ALLOC_CALL(ctx.interface(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fRTFBOID)); 826 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fRTFBOID));
918 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 827 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
919 GR_GL_COLOR_ATTACHMENT0, 828 GR_GL_COLOR_ATTACHMENT0,
920 GR_GL_RENDERBUFFER, 829 GR_GL_RENDERBUFFER,
921 desc->fMSColorRenderbufferID)); 830 desc->fMSColorRenderbufferID));
922 if (!this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { 831 if (!this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) {
923 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 832 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
924 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 833 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
925 goto FAILED; 834 goto FAILED;
926 } 835 }
927 fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fCon fig); 836 fGLContext.info().caps()->markConfigAsValidColorAttachment(desc->fCo nfig);
928 } 837 }
929 } 838 }
930 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID)); 839 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID));
931 840
932 if (GrGLCaps::kImaginationES_MSFBOType == this->glCaps().msFBOType() && desc ->fSampleCnt > 0) { 841 if (GrGLCaps::kImaginationES_MSFBOType == this->glCaps().msFBOType() && desc ->fSampleCnt > 0) {
933 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, 842 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER,
934 GR_GL_COLOR_ATTACHMENT0, 843 GR_GL_COLOR_ATTACHMENT0,
935 GR_GL_TEXTURE_2D, 844 GR_GL_TEXTURE_2D,
936 texID, 0, desc->fSampleCnt)); 845 texID, 0, desc->fSampleCnt));
937 } else { 846 } else {
938 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, 847 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
939 GR_GL_COLOR_ATTACHMENT0, 848 GR_GL_COLOR_ATTACHMENT0,
940 GR_GL_TEXTURE_2D, 849 GR_GL_TEXTURE_2D,
941 texID, 0)); 850 texID, 0));
942 } 851 }
943 if (!this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { 852 if (!this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) {
944 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 853 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
945 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 854 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
946 goto FAILED; 855 goto FAILED;
947 } 856 }
948 fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fConfig) ; 857 fGLContext.info().caps()->markConfigAsValidColorAttachment(desc->fConfig );
949 } 858 }
950 859
951 return true; 860 return true;
952 861
953 FAILED: 862 FAILED:
954 if (desc->fMSColorRenderbufferID) { 863 if (desc->fMSColorRenderbufferID) {
955 GL_CALL(DeleteRenderbuffers(1, &desc->fMSColorRenderbufferID)); 864 GL_CALL(DeleteRenderbuffers(1, &desc->fMSColorRenderbufferID));
956 } 865 }
957 if (desc->fRTFBOID != desc->fTexFBOID) { 866 if (desc->fRTFBOID != desc->fTexFBOID) {
958 GL_CALL(DeleteFramebuffers(1, &desc->fRTFBOID)); 867 GL_CALL(DeleteFramebuffers(1, &desc->fRTFBOID));
(...skipping 24 matching lines...) Expand all
983 GrGLRenderTarget::Desc glRTDesc; 892 GrGLRenderTarget::Desc glRTDesc;
984 893
985 // Attempt to catch un- or wrongly initialized sample counts; 894 // Attempt to catch un- or wrongly initialized sample counts;
986 GrAssert(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); 895 GrAssert(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64);
987 // We fail if the MSAA was requested and is not available. 896 // We fail if the MSAA was requested and is not available.
988 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) { 897 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) {
989 //GrPrintf("MSAA RT requested but not supported on this platform."); 898 //GrPrintf("MSAA RT requested but not supported on this platform.");
990 return return_null_texture(); 899 return return_null_texture();
991 } 900 }
992 // If the sample count exceeds the max then we clamp it. 901 // If the sample count exceeds the max then we clamp it.
993 glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->getCaps().maxSampleCount ()); 902 glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->caps()->maxSampleCount() );
994 903
995 glTexDesc.fFlags = desc.fFlags; 904 glTexDesc.fFlags = desc.fFlags;
996 glTexDesc.fWidth = desc.fWidth; 905 glTexDesc.fWidth = desc.fWidth;
997 glTexDesc.fHeight = desc.fHeight; 906 glTexDesc.fHeight = desc.fHeight;
998 glTexDesc.fConfig = desc.fConfig; 907 glTexDesc.fConfig = desc.fConfig;
999 glTexDesc.fIsWrapped = false; 908 glTexDesc.fIsWrapped = false;
1000 909
1001 glRTDesc.fMSColorRenderbufferID = 0; 910 glRTDesc.fMSColorRenderbufferID = 0;
1002 glRTDesc.fRTFBOID = 0; 911 glRTDesc.fRTFBOID = 0;
1003 glRTDesc.fTexFBOID = 0; 912 glRTDesc.fTexFBOID = 0;
1004 glRTDesc.fIsWrapped = false; 913 glRTDesc.fIsWrapped = false;
1005 glRTDesc.fConfig = glTexDesc.fConfig; 914 glRTDesc.fConfig = glTexDesc.fConfig;
1006 915
1007 bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit); 916 bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit);
1008 917
1009 const Caps& caps = this->getCaps();
1010
1011 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); 918 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
1012 glRTDesc.fOrigin = glTexDesc.fOrigin; 919 glRTDesc.fOrigin = glTexDesc.fOrigin;
1013 920
1014 glRTDesc.fSampleCnt = glTexDesc.fSampleCnt; 921 glRTDesc.fSampleCnt = glTexDesc.fSampleCnt;
1015 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && 922 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() &&
1016 desc.fSampleCnt) { 923 desc.fSampleCnt) {
1017 //GrPrintf("MSAA RT requested but not supported on this platform."); 924 //GrPrintf("MSAA RT requested but not supported on this platform.");
1018 return return_null_texture(); 925 return return_null_texture();
1019 } 926 }
1020 927
1021 if (renderTarget) { 928 if (renderTarget) {
1022 if (glTexDesc.fWidth > caps.maxRenderTargetSize() || 929 int maxRTSize = this->caps()->maxRenderTargetSize();
1023 glTexDesc.fHeight > caps.maxRenderTargetSize()) { 930 if (glTexDesc.fWidth > maxRTSize || glTexDesc.fHeight > maxRTSize) {
1024 return return_null_texture(); 931 return return_null_texture();
1025 } 932 }
1026 } 933 }
1027 934
1028 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); 935 GL_CALL(GenTextures(1, &glTexDesc.fTextureID));
1029 if (renderTarget && this->glCaps().textureUsageSupport()) { 936 if (renderTarget && this->glCaps().textureUsageSupport()) {
1030 // provides a hint about how this texture will be used 937 // provides a hint about how this texture will be used
1031 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 938 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1032 GR_GL_TEXTURE_USAGE, 939 GR_GL_TEXTURE_USAGE,
1033 GR_GL_FRAMEBUFFER_ATTACHMENT)); 940 GR_GL_FRAMEBUFFER_ATTACHMENT));
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1134 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1228 GR_GL_STENCIL_ATTACHMENT, 1135 GR_GL_STENCIL_ATTACHMENT,
1229 GR_GL_RENDERBUFFER, 0)); 1136 GR_GL_RENDERBUFFER, 0));
1230 if (glsb->format().fPacked) { 1137 if (glsb->format().fPacked) {
1231 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1138 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1232 GR_GL_DEPTH_ATTACHMENT, 1139 GR_GL_DEPTH_ATTACHMENT,
1233 GR_GL_RENDERBUFFER, 0)); 1140 GR_GL_RENDERBUFFER, 0));
1234 } 1141 }
1235 return false; 1142 return false;
1236 } else { 1143 } else {
1237 fGLContext.info().caps().markColorConfigAndStencilFormatAsVerifi ed( 1144 fGLContext.info().caps()->markColorConfigAndStencilFormatAsVerif ied(
1238 rt->config(), 1145 rt->config(),
1239 glsb->format()); 1146 glsb->format());
1240 } 1147 }
1241 } 1148 }
1242 return true; 1149 return true;
1243 } 1150 }
1244 } 1151 }
1245 1152
1246 //////////////////////////////////////////////////////////////////////////////// 1153 ////////////////////////////////////////////////////////////////////////////////
1247 1154
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 return NULL; 1212 return NULL;
1306 } 1213 }
1307 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc )); 1214 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc ));
1308 return indexBuffer; 1215 return indexBuffer;
1309 } 1216 }
1310 return NULL; 1217 return NULL;
1311 } 1218 }
1312 } 1219 }
1313 1220
1314 GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) { 1221 GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) {
1315 GrAssert(fCaps.pathStencilingSupport()); 1222 GrAssert(this->caps()->pathStencilingSupport());
1316 return SkNEW_ARGS(GrGLPath, (this, inPath)); 1223 return SkNEW_ARGS(GrGLPath, (this, inPath));
1317 } 1224 }
1318 1225
1319 void GrGpuGL::flushScissor() { 1226 void GrGpuGL::flushScissor() {
1320 const GrDrawState& drawState = this->getDrawState(); 1227 const GrDrawState& drawState = this->getDrawState();
1321 const GrGLRenderTarget* rt = 1228 const GrGLRenderTarget* rt =
1322 static_cast<const GrGLRenderTarget*>(drawState.getRenderTarget()); 1229 static_cast<const GrGLRenderTarget*>(drawState.getRenderTarget());
1323 1230
1324 GrAssert(NULL != rt); 1231 GrAssert(NULL != rt);
1325 const GrGLIRect& vp = rt->getViewport(); 1232 const GrGLIRect& vp = rt->getViewport();
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 return; 1635 return;
1729 case SkPath::kWinding_FillType: 1636 case SkPath::kWinding_FillType:
1730 *settings = winding_nv_path_stencil_settings(); 1637 *settings = winding_nv_path_stencil_settings();
1731 return; 1638 return;
1732 default: 1639 default:
1733 GrCrash("Unexpected path fill."); 1640 GrCrash("Unexpected path fill.");
1734 } 1641 }
1735 } 1642 }
1736 1643
1737 void GrGpuGL::onGpuStencilPath(const GrPath* path, SkPath::FillType fill) { 1644 void GrGpuGL::onGpuStencilPath(const GrPath* path, SkPath::FillType fill) {
1738 GrAssert(fCaps.pathStencilingSupport()); 1645 GrAssert(this->caps()->pathStencilingSupport());
1739 1646
1740 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 1647 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
1741 GrDrawState* drawState = this->drawState(); 1648 GrDrawState* drawState = this->drawState();
1742 GrAssert(NULL != drawState->getRenderTarget()); 1649 GrAssert(NULL != drawState->getRenderTarget());
1743 if (NULL == drawState->getRenderTarget()->getStencilBuffer()) { 1650 if (NULL == drawState->getRenderTarget()->getStencilBuffer()) {
1744 return; 1651 return;
1745 } 1652 }
1746 1653
1747 // Decide how to manipulate the stencil buffer based on the fill rule. 1654 // Decide how to manipulate the stencil buffer based on the fill rule.
1748 // Also, assert that the stencil settings we set in setStencilPathSettings 1655 // Also, assert that the stencil settings we set in setStencilPathSettings
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 GL_CALL(Disable(GR_GL_STENCIL_TEST)); 1818 GL_CALL(Disable(GR_GL_STENCIL_TEST));
1912 fHWStencilTestEnabled = kNo_TriState; 1819 fHWStencilTestEnabled = kNo_TriState;
1913 } 1820 }
1914 } else { 1821 } else {
1915 if (kYes_TriState != fHWStencilTestEnabled) { 1822 if (kYes_TriState != fHWStencilTestEnabled) {
1916 GL_CALL(Enable(GR_GL_STENCIL_TEST)); 1823 GL_CALL(Enable(GR_GL_STENCIL_TEST));
1917 fHWStencilTestEnabled = kYes_TriState; 1824 fHWStencilTestEnabled = kYes_TriState;
1918 } 1825 }
1919 } 1826 }
1920 if (!fStencilSettings.isDisabled()) { 1827 if (!fStencilSettings.isDisabled()) {
1921 if (this->getCaps().twoSidedStencilSupport()) { 1828 if (this->caps()->twoSidedStencilSupport()) {
1922 set_gl_stencil(this->glInterface(), 1829 set_gl_stencil(this->glInterface(),
1923 fStencilSettings, 1830 fStencilSettings,
1924 GR_GL_FRONT, 1831 GR_GL_FRONT,
1925 GrStencilSettings::kFront_Face); 1832 GrStencilSettings::kFront_Face);
1926 set_gl_stencil(this->glInterface(), 1833 set_gl_stencil(this->glInterface(),
1927 fStencilSettings, 1834 fStencilSettings,
1928 GR_GL_BACK, 1835 GR_GL_BACK,
1929 GrStencilSettings::kBack_Face); 1836 GrStencilSettings::kBack_Face);
1930 } else { 1837 } else {
1931 set_gl_stencil(this->glInterface(), 1838 set_gl_stencil(this->glInterface(),
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 *internalFormat = GR_GL_RGBA; 2168 *internalFormat = GR_GL_RGBA;
2262 *externalFormat = GR_GL_RGBA; 2169 *externalFormat = GR_GL_RGBA;
2263 if (getSizedInternalFormat) { 2170 if (getSizedInternalFormat) {
2264 *internalFormat = GR_GL_RGBA4; 2171 *internalFormat = GR_GL_RGBA4;
2265 } else { 2172 } else {
2266 *internalFormat = GR_GL_RGBA; 2173 *internalFormat = GR_GL_RGBA;
2267 } 2174 }
2268 *externalType = GR_GL_UNSIGNED_SHORT_4_4_4_4; 2175 *externalType = GR_GL_UNSIGNED_SHORT_4_4_4_4;
2269 break; 2176 break;
2270 case kIndex_8_GrPixelConfig: 2177 case kIndex_8_GrPixelConfig:
2271 if (this->getCaps().eightBitPaletteSupport()) { 2178 if (this->caps()->eightBitPaletteSupport()) {
2272 *internalFormat = GR_GL_PALETTE8_RGBA8; 2179 *internalFormat = GR_GL_PALETTE8_RGBA8;
2273 // glCompressedTexImage doesn't take external params 2180 // glCompressedTexImage doesn't take external params
2274 *externalFormat = GR_GL_PALETTE8_RGBA8; 2181 *externalFormat = GR_GL_PALETTE8_RGBA8;
2275 // no sized/unsized internal format distinction here 2182 // no sized/unsized internal format distinction here
2276 *internalFormat = GR_GL_PALETTE8_RGBA8; 2183 *internalFormat = GR_GL_PALETTE8_RGBA8;
2277 // unused with CompressedTexImage 2184 // unused with CompressedTexImage
2278 *externalType = GR_GL_UNSIGNED_BYTE; 2185 *externalType = GR_GL_UNSIGNED_BYTE;
2279 } else { 2186 } else {
2280 return false; 2187 return false;
2281 } 2188 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 this->setVertexArrayID(gpu, 0); 2254 this->setVertexArrayID(gpu, 0);
2348 } 2255 }
2349 int attrCount = gpu->glCaps().maxVertexAttributes(); 2256 int attrCount = gpu->glCaps().maxVertexAttributes();
2350 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2257 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2351 fDefaultVertexArrayAttribState.resize(attrCount); 2258 fDefaultVertexArrayAttribState.resize(attrCount);
2352 } 2259 }
2353 attribState = &fDefaultVertexArrayAttribState; 2260 attribState = &fDefaultVertexArrayAttribState;
2354 } 2261 }
2355 return attribState; 2262 return attribState;
2356 } 2263 }
OLDNEW
« src/gpu/gl/GrGLContext.cpp ('K') | « src/gpu/gl/GrGpuGL.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698