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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 169933002: WebGL: Don't destroy mailbox textures in the destructor until they're released. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix crash Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 712
713 if (!m_drawingBuffer) 713 if (!m_drawingBuffer)
714 return; 714 return;
715 715
716 m_extensionsUtil.clear(); 716 m_extensionsUtil.clear();
717 717
718 webContext()->setContextLostCallback(0); 718 webContext()->setContextLostCallback(0);
719 webContext()->setErrorMessageCallback(0); 719 webContext()->setErrorMessageCallback(0);
720 720
721 ASSERT(m_drawingBuffer); 721 ASSERT(m_drawingBuffer);
722 m_drawingBuffer->beginDestruction();
722 m_drawingBuffer.clear(); 723 m_drawingBuffer.clear();
723 } 724 }
724 725
725 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) 726 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType)
726 { 727 {
727 if (m_framebufferBinding || isContextLost()) 728 if (m_framebufferBinding || isContextLost())
728 return; 729 return;
729 730
730 m_drawingBuffer->markContentsChanged(); 731 m_drawingBuffer->markContentsChanged();
731 732
(...skipping 4630 matching lines...) Expand 10 before | Expand all | Expand 10 after
5362 LocalFrame* frame = canvas()->document().frame(); 5363 LocalFrame* frame = canvas()->document().frame();
5363 if (!frame) 5364 if (!frame)
5364 return; 5365 return;
5365 5366
5366 Settings* settings = frame->settings(); 5367 Settings* settings = frame->settings();
5367 5368
5368 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) 5369 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ()))
5369 return; 5370 return;
5370 5371
5371 // If the context was lost due to RealLostContext, we need to destroy the ol d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou gh. 5372 // If the context was lost due to RealLostContext, we need to destroy the ol d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou gh.
5372 m_drawingBuffer.clear(); 5373 if (m_drawingBuffer) {
5374 m_drawingBuffer->beginDestruction();
5375 m_drawingBuffer.clear();
5376 }
5373 5377
5374 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings); 5378 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings);
5375 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0)); 5379 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0));
5376 RefPtr<DrawingBuffer> drawingBuffer; 5380 RefPtr<DrawingBuffer> drawingBuffer;
5377 if (context) { 5381 if (context) {
5378 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad optRef(new WebGLRenderingContextEvictionManager()); 5382 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad optRef(new WebGLRenderingContextEvictionManager());
5379 5383
5380 // Construct a new drawing buffer with the new WebGraphicsContext3D. 5384 // Construct a new drawing buffer with the new WebGraphicsContext3D.
5381 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; 5385 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
5382 drawingBuffer = DrawingBuffer::create(context.release(), clampedCanvasSi ze(), preserve, contextEvictionManager.release()); 5386 drawingBuffer = DrawingBuffer::create(context.release(), clampedCanvasSi ze(), preserve, contextEvictionManager.release());
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5590 if (m_textureUnits[i].m_texture2DBinding 5594 if (m_textureUnits[i].m_texture2DBinding
5591 || m_textureUnits[i].m_textureCubeMapBinding) { 5595 || m_textureUnits[i].m_textureCubeMapBinding) {
5592 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5596 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5593 return; 5597 return;
5594 } 5598 }
5595 } 5599 }
5596 m_onePlusMaxNonDefaultTextureUnit = 0; 5600 m_onePlusMaxNonDefaultTextureUnit = 0;
5597 } 5601 }
5598 5602
5599 } // namespace WebCore 5603 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/gpu/DrawingBuffer.h » ('j') | Source/platform/graphics/gpu/DrawingBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698