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

Side by Side Diff: ui/gl/gl_surface_ozone.cc

Issue 1865603002: ozone: Don't take a self reference in surfaceless adapter dtor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: be extra paranoid about IsCurrent() 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 | « no previous file | 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 571 }
572 GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback); 572 GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback);
573 current_surface_ ^= 1; 573 current_surface_ ^= 1;
574 BindFramebuffer(); 574 BindFramebuffer();
575 } 575 }
576 576
577 void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() { 577 void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
578 if (!context_) 578 if (!context_)
579 return; 579 return;
580 scoped_refptr<gfx::GLContext> previous_context = gfx::GLContext::GetCurrent(); 580 scoped_refptr<gfx::GLContext> previous_context = gfx::GLContext::GetCurrent();
581 scoped_refptr<gfx::GLSurface> previous_surface = gfx::GLSurface::GetCurrent(); 581 scoped_refptr<gfx::GLSurface> previous_surface;
582 context_->MakeCurrent(this); 582
583 bool was_current = previous_context && previous_context->IsCurrent(nullptr) &&
584 gfx::GLSurface::GetCurrent() == this;
585 if (!was_current) {
586 // Only take a reference to previous surface if it's not |this|
587 // because otherwise we can take a self reference from our own dtor.
588 previous_surface = gfx::GLSurface::GetCurrent();
589 context_->MakeCurrent(this);
590 }
583 591
584 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); 592 glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
585 if (fbo_) { 593 if (fbo_) {
586 glDeleteTextures(arraysize(textures_), textures_); 594 glDeleteTextures(arraysize(textures_), textures_);
587 for (auto& texture : textures_) 595 for (auto& texture : textures_)
588 texture = 0; 596 texture = 0;
589 glDeleteFramebuffersEXT(1, &fbo_); 597 glDeleteFramebuffersEXT(1, &fbo_);
590 fbo_ = 0; 598 fbo_ = 0;
591 } 599 }
592 for (auto image : images_) { 600 for (auto image : images_) {
593 if (image) 601 if (image)
594 image->Destroy(true); 602 image->Destroy(true);
595 } 603 }
596 604
597 if (previous_context.get()) { 605 if (!was_current) {
598 previous_context->MakeCurrent(previous_surface.get()); 606 previous_context->MakeCurrent(previous_surface.get());
599 } else { 607 } else {
600 context_->ReleaseCurrent(this); 608 context_->ReleaseCurrent(this);
601 } 609 }
602 } 610 }
603 611
604 bool GLSurfaceOzoneSurfacelessSurfaceImpl::IsSurfaceless() const { 612 bool GLSurfaceOzoneSurfacelessSurfaceImpl::IsSurfaceless() const {
605 return false; 613 return false;
606 } 614 }
607 615
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 } 780 }
773 } 781 }
774 782
775 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 783 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
776 return ui::OzonePlatform::GetInstance() 784 return ui::OzonePlatform::GetInstance()
777 ->GetSurfaceFactoryOzone() 785 ->GetSurfaceFactoryOzone()
778 ->GetNativeDisplay(); 786 ->GetNativeDisplay();
779 } 787 }
780 788
781 } // namespace gfx 789 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698