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

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

Issue 17027003: Add flag bits for partial GrContext reset (Closed)
Patch Set: Fixes (prev checkin was reverted due to assertions) Created 7 years, 5 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
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | 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 * 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 ctx.info().extensions().print(); 146 ctx.info().extensions().print();
147 GrPrintf("\n"); 147 GrPrintf("\n");
148 ctx.info().caps()->print(); 148 ctx.info().caps()->print();
149 } 149 }
150 150
151 fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext())); 151 fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext()));
152 152
153 GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr ibCnt); 153 GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr ibCnt);
154 154
155 fLastSuccessfulStencilFmtIdx = 0; 155 fLastSuccessfulStencilFmtIdx = 0;
156 fHWProgramID = 0;
156 } 157 }
157 158
158 GrGpuGL::~GrGpuGL() { 159 GrGpuGL::~GrGpuGL() {
159 if (0 != fHWProgramID) { 160 if (0 != fHWProgramID) {
160 // detach the current program so there is no confusion on OpenGL's part 161 // detach the current program so there is no confusion on OpenGL's part
161 // that we want it to be deleted 162 // that we want it to be deleted
162 GrAssert(fHWProgramID == fCurrentProgram->programID()); 163 GrAssert(fHWProgramID == fCurrentProgram->programID());
163 GL_CALL(UseProgram(0)); 164 GL_CALL(UseProgram(0));
164 } 165 }
165 166
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 276 }
276 } else { 277 } else {
277 return true; 278 return true;
278 } 279 }
279 } 280 }
280 281
281 bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const { 282 bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const {
282 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL); 283 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL);
283 } 284 }
284 285
285 void GrGpuGL::onResetContext() { 286 void GrGpuGL::onResetContext(uint32_t resetBits) {
287 // we don't use the zb at all
288 if (resetBits & kMisc_GrGLBackendState) {
289 GL_CALL(Disable(GR_GL_DEPTH_TEST));
290 GL_CALL(DepthMask(GR_GL_FALSE));
286 291
287 // we don't use the zb at all 292 fHWDrawFace = GrDrawState::kInvalid_DrawFace;
288 GL_CALL(Disable(GR_GL_DEPTH_TEST)); 293 fHWDitherEnabled = kUnknown_TriState;
289 GL_CALL(DepthMask(GR_GL_FALSE));
290 294
291 fHWDrawFace = GrDrawState::kInvalid_DrawFace; 295 if (kDesktop_GrGLBinding == this->glBinding()) {
292 fHWDitherEnabled = kUnknown_TriState; 296 // Desktop-only state that we never change
297 if (!this->glCaps().isCoreProfile()) {
298 GL_CALL(Disable(GR_GL_POINT_SMOOTH));
299 GL_CALL(Disable(GR_GL_LINE_SMOOTH));
300 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
301 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
302 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
303 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
304 }
305 // The windows NVIDIA driver has GL_ARB_imaging in the extension str ing when using a
306 // core profile. This seems like a bug since the core spec removes a ny mention of
307 // GL_ARB_imaging.
308 if (this->glCaps().imagingSupport() && !this->glCaps().isCoreProfile ()) {
309 GL_CALL(Disable(GR_GL_COLOR_TABLE));
310 }
311 GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL));
312 // Since ES doesn't support glPointSize at all we always use the VS to
313 // set the point size
314 GL_CALL(Enable(GR_GL_VERTEX_PROGRAM_POINT_SIZE));
293 315
294 if (kDesktop_GrGLBinding == this->glBinding()) { 316 // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It is n't
295 // Desktop-only state that we never change 317 // currently part of our gl interface. There are probably others as
296 if (!this->glCaps().isCoreProfile()) { 318 // well.
297 GL_CALL(Disable(GR_GL_POINT_SMOOTH));
298 GL_CALL(Disable(GR_GL_LINE_SMOOTH));
299 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
300 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
301 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
302 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
303 } 319 }
304 // The windows NVIDIA driver has GL_ARB_imaging in the extension string when using a core 320 fHWWriteToColor = kUnknown_TriState;
305 // profile. This seems like a bug since the core spec removes any mentio n of GL_ARB_imaging. 321 // we only ever use lines in hairline mode
306 if (this->glCaps().imagingSupport() && !this->glCaps().isCoreProfile()) { 322 GL_CALL(LineWidth(1));
307 GL_CALL(Disable(GR_GL_COLOR_TABLE)); 323 }
308 }
309 GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL));
310 // Since ES doesn't support glPointSize at all we always use the VS to
311 // set the point size
312 GL_CALL(Enable(GR_GL_VERTEX_PROGRAM_POINT_SIZE));
313 324
314 // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It isn't 325 if (resetBits & kAA_GrGLBackendState) {
315 // currently part of our gl interface. There are probably others as 326 fHWAAState.invalidate();
316 // well.
317 } 327 }
318 fHWAAState.invalidate();
319 fHWWriteToColor = kUnknown_TriState;
320
321 // we only ever use lines in hairline mode
322 GL_CALL(LineWidth(1));
323 328
324 // invalid 329 // invalid
325 fHWActiveTextureUnitIdx = -1; 330 if (resetBits & kTextureBinding_GrGLBackendState) {
326 331 fHWActiveTextureUnitIdx = -1;
327 fHWBlendState.invalidate(); 332 for (int s = 0; s < fHWBoundTextures.count(); ++s) {
328 333 fHWBoundTextures[s] = NULL;
329 for (int s = 0; s < fHWBoundTextures.count(); ++s) { 334 }
330 fHWBoundTextures[s] = NULL;
331 } 335 }
332 336
333 fHWScissorSettings.invalidate(); 337 if (resetBits & kBlend_GrGLBackendState) {
338 fHWBlendState.invalidate();
339 }
334 340
335 fHWViewport.invalidate(); 341 if (resetBits & kView_GrGLBackendState) {
342 fHWScissorSettings.invalidate();
343 fHWViewport.invalidate();
344 }
336 345
337 fHWStencilSettings.invalidate(); 346 if (resetBits & kStencil_GrGLBackendState) {
338 fHWStencilTestEnabled = kUnknown_TriState; 347 fHWStencilSettings.invalidate();
348 fHWStencilTestEnabled = kUnknown_TriState;
349 }
339 350
340 fHWGeometryState.invalidate(); 351 // Vertex
352 if (resetBits & kVertex_GrGLBackendState) {
353 fHWGeometryState.invalidate();
354 }
341 355
342 fHWBoundRenderTarget = NULL; 356 if (resetBits & kRenderTarget_GrGLBackendState) {
357 fHWBoundRenderTarget = NULL;
358 }
343 359
344 fHWPathStencilMatrixState.invalidate(); 360 if (resetBits & kPathStencil_GrGLBackendState) {
345 if (this->caps()->pathStencilingSupport()) { 361 fHWPathStencilMatrixState.invalidate();
346 // we don't use the model view matrix. 362 if (this->caps()->pathStencilingSupport()) {
347 GL_CALL(MatrixMode(GR_GL_MODELVIEW)); 363 // we don't use the model view matrix.
348 GL_CALL(LoadIdentity()); 364 GL_CALL(MatrixMode(GR_GL_MODELVIEW));
365 GL_CALL(LoadIdentity());
366 }
349 } 367 }
350 368
351 // we assume these values 369 // we assume these values
352 if (this->glCaps().unpackRowLengthSupport()) { 370 if (resetBits & kPixelStore_GrGLBackendState) {
353 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); 371 if (this->glCaps().unpackRowLengthSupport()) {
354 } 372 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
355 if (this->glCaps().packRowLengthSupport()) { 373 }
356 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0)); 374 if (this->glCaps().packRowLengthSupport()) {
357 } 375 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
358 if (this->glCaps().unpackFlipYSupport()) { 376 }
359 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); 377 if (this->glCaps().unpackFlipYSupport()) {
360 } 378 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
361 if (this->glCaps().packFlipYSupport()) { 379 }
362 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE)); 380 if (this->glCaps().packFlipYSupport()) {
381 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE));
382 }
363 } 383 }
364 384
365 fHWProgramID = 0; 385 if (resetBits & kProgram_GrGLBackendState) {
366 fSharedGLProgramState.invalidate(); 386 fHWProgramID = 0;
387 fSharedGLProgramState.invalidate();
388 }
367 } 389 }
368 390
369 namespace { 391 namespace {
370 392
371 GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) { 393 GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) {
372 // By default, GrRenderTargets are GL's normal orientation so that they 394 // By default, GrRenderTargets are GL's normal orientation so that they
373 // can be drawn to by the outside world without the client having 395 // can be drawn to by the outside world without the client having
374 // to render upside down. 396 // to render upside down.
375 if (kDefault_GrSurfaceOrigin == origin) { 397 if (kDefault_GrSurfaceOrigin == origin) {
376 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; 398 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin;
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 this->setVertexArrayID(gpu, 0); 2515 this->setVertexArrayID(gpu, 0);
2494 } 2516 }
2495 int attrCount = gpu->glCaps().maxVertexAttributes(); 2517 int attrCount = gpu->glCaps().maxVertexAttributes();
2496 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2518 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2497 fDefaultVertexArrayAttribState.resize(attrCount); 2519 fDefaultVertexArrayAttribState.resize(attrCount);
2498 } 2520 }
2499 attribState = &fDefaultVertexArrayAttribState; 2521 attribState = &fDefaultVertexArrayAttribState;
2500 } 2522 }
2501 return attribState; 2523 return attribState;
2502 } 2524 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698