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

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

Issue 1852733002: Add GrContext::releaseAndAbandonContext() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-gpu build, add null check, add unit test" Created 4 years, 8 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/GrGLGpu.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('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 * 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 #include "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 1, 0, 379 1, 0,
380 1, 1 380 1, 1
381 }; 381 };
382 GL_ALLOC_CALL(this->glInterface(), 382 GL_ALLOC_CALL(this->glInterface(),
383 BufferData(GR_GL_ARRAY_BUFFER, 383 BufferData(GR_GL_ARRAY_BUFFER,
384 (GrGLsizeiptr) sizeof(vdata), 384 (GrGLsizeiptr) sizeof(vdata),
385 vdata, // data ptr 385 vdata, // data ptr
386 GR_GL_STATIC_DRAW)); 386 GR_GL_STATIC_DRAW));
387 } 387 }
388 388
389 void GrGLGpu::contextAbandoned() { 389 void GrGLGpu::disconnect(DisconnectType type) {
390 INHERITED::contextAbandoned(); 390 INHERITED::disconnect(type);
391 fProgramCache->abandon(); 391 if (DisconnectType::kCleanup == type) {
392 if (fHWProgramID) {
393 GL_CALL(UseProgram(0));
394 }
395 if (fTempSrcFBOID) {
396 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID));
397 }
398 if (fTempDstFBOID) {
399 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID));
400 }
401 if (fStencilClearFBOID) {
402 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID));
403 }
404 if (fCopyProgramArrayBuffer) {
405 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer));
406 }
407 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) {
408 if (fCopyPrograms[i].fProgram) {
409 GL_CALL(DeleteProgram(fCopyPrograms[i].fProgram));
410 }
411 }
412 if (fWireRectProgram.fProgram) {
413 GL_CALL(DeleteProgram(fWireRectProgram.fProgram));
414 }
415 if (fWireRectArrayBuffer) {
416 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer));
417 }
418
419 if (fPLSSetupProgram.fProgram) {
420 GL_CALL(DeleteProgram(fPLSSetupProgram.fProgram));
421 }
422 if (fPLSSetupProgram.fArrayBuffer) {
423 GL_CALL(DeleteBuffers(1, &fPLSSetupProgram.fArrayBuffer));
424 }
425 } else {
426 if (fProgramCache) {
427 fProgramCache->abandon();
428 }
429 }
430
431 delete fProgramCache;
432 fProgramCache = nullptr;
433
392 fHWProgramID = 0; 434 fHWProgramID = 0;
393 fTempSrcFBOID = 0; 435 fTempSrcFBOID = 0;
394 fTempDstFBOID = 0; 436 fTempDstFBOID = 0;
395 fStencilClearFBOID = 0; 437 fStencilClearFBOID = 0;
396 fCopyProgramArrayBuffer = 0; 438 fCopyProgramArrayBuffer = 0;
397 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { 439 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) {
398 fCopyPrograms[i].fProgram = 0; 440 fCopyPrograms[i].fProgram = 0;
399 } 441 }
400 fWireRectProgram.fProgram = 0; 442 fWireRectProgram.fProgram = 0;
401 fWireRectArrayBuffer = 0; 443 fWireRectArrayBuffer = 0;
444 fPLSSetupProgram.fProgram = 0;
445 fPLSSetupProgram.fArrayBuffer = 0;
402 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { 446 if (this->glCaps().shaderCaps()->pathRenderingSupport()) {
403 this->glPathRendering()->abandonGpuResources(); 447 this->glPathRendering()->disconnect(type);
404 } 448 }
405 } 449 }
406 450
407 /////////////////////////////////////////////////////////////////////////////// 451 ///////////////////////////////////////////////////////////////////////////////
408 452
409 void GrGLGpu::onResetContext(uint32_t resetBits) { 453 void GrGLGpu::onResetContext(uint32_t resetBits) {
410 // we don't use the zb at all 454 // we don't use the zb at all
411 if (resetBits & kMisc_GrGLBackendState) { 455 if (resetBits & kMisc_GrGLBackendState) {
412 GL_CALL(Disable(GR_GL_DEPTH_TEST)); 456 GL_CALL(Disable(GR_GL_DEPTH_TEST));
413 GL_CALL(DepthMask(GR_GL_FALSE)); 457 GL_CALL(DepthMask(GR_GL_FALSE));
(...skipping 3806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4264 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4221 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4265 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4222 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4266 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4223 copyParams->fWidth = texture->width(); 4267 copyParams->fWidth = texture->width();
4224 copyParams->fHeight = texture->height(); 4268 copyParams->fHeight = texture->height();
4225 return true; 4269 return true;
4226 } 4270 }
4227 } 4271 }
4228 return false; 4272 return false;
4229 } 4273 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698