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

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

Issue 15876011: Make WebGL extensions get lost when context is lost. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 #include "core/html/canvas/EXTDrawBuffers.h" 28 #include "core/html/canvas/EXTDrawBuffers.h"
29 29
30 #include "core/platform/graphics/Extensions3D.h" 30 #include "core/platform/graphics/Extensions3D.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 EXTDrawBuffers::EXTDrawBuffers(WebGLRenderingContext* context) 34 EXTDrawBuffers::EXTDrawBuffers(WebGLRenderingContext* context)
35 : WebGLExtension(context) 35 : WebGLExtension(context)
36 { 36 {
37 ScriptWrappable::init(this); 37 ScriptWrappable::init(this);
38 context->graphicsContext3D()->getExtensions()->ensureEnabled("GL_EXT_draw_bu ffers"); 38 enable();
39 } 39 }
40 40
41 EXTDrawBuffers::~EXTDrawBuffers() 41 EXTDrawBuffers::~EXTDrawBuffers()
42 { 42 {
43 } 43 }
44 44
45 void EXTDrawBuffers::enable()
46 {
47 m_context->graphicsContext3D()->getExtensions()->ensureEnabled("GL_EXT_draw_ buffers");
48 }
49
45 WebGLExtension::ExtensionName EXTDrawBuffers::getName() const 50 WebGLExtension::ExtensionName EXTDrawBuffers::getName() const
46 { 51 {
47 return WebGLExtension::EXTDrawBuffersName; 52 return WebGLExtension::EXTDrawBuffersName;
48 } 53 }
49 54
50 PassOwnPtr<EXTDrawBuffers> EXTDrawBuffers::create(WebGLRenderingContext* context ) 55 PassOwnPtr<EXTDrawBuffers> EXTDrawBuffers::create(WebGLRenderingContext* context )
51 { 56 {
52 return adoptPtr(new EXTDrawBuffers(context)); 57 return adoptPtr(new EXTDrawBuffers(context));
53 } 58 }
54 59
55 // static 60 // static
56 bool EXTDrawBuffers::supported(WebGLRenderingContext* context) 61 bool EXTDrawBuffers::supported(WebGLRenderingContext* context)
57 { 62 {
58 Extensions3D* extensions = context->graphicsContext3D()->getExtensions(); 63 Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
59 return (extensions->supports("GL_EXT_draw_buffers") 64 return (extensions->supports("GL_EXT_draw_buffers")
60 && satisfiesWebGLRequirements(context)); 65 && satisfiesWebGLRequirements(context));
61 } 66 }
62 67
63 const char* EXTDrawBuffers::getExtensionName() 68 const char* EXTDrawBuffers::getExtensionName()
64 { 69 {
65 return "EXT_draw_buffers"; 70 return "EXT_draw_buffers";
66 } 71 }
67 72
68 void EXTDrawBuffers::drawBuffersEXT(const Vector<GC3Denum>& buffers) 73 void EXTDrawBuffers::drawBuffersEXT(const Vector<GC3Denum>& buffers)
69 { 74 {
70 if (m_context->isContextLost()) 75 if (isLost())
71 return; 76 return;
72 GC3Dsizei n = buffers.size(); 77 GC3Dsizei n = buffers.size();
73 const GC3Denum* bufs = buffers.data(); 78 const GC3Denum* bufs = buffers.data();
74 if (!m_context->m_framebufferBinding) { 79 if (!m_context->m_framebufferBinding) {
75 if (n != 1) { 80 if (n != 1) {
76 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "draw BuffersEXT", "more than one buffer"); 81 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "draw BuffersEXT", "more than one buffer");
77 return; 82 return;
78 } 83 }
79 if (bufs[0] != GraphicsContext3D::BACK && bufs[0] != GraphicsContext3D:: NONE) { 84 if (bufs[0] != GraphicsContext3D::BACK && bufs[0] != GraphicsContext3D:: NONE) {
80 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, " drawBuffersEXT", "BACK or NONE"); 85 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, " drawBuffersEXT", "BACK or NONE");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (supportsDepth) 178 if (supportsDepth)
174 context->deleteTexture(depth); 179 context->deleteTexture(depth);
175 if (supportsDepthStencil) 180 if (supportsDepthStencil)
176 context->deleteTexture(depthStencil); 181 context->deleteTexture(depthStencil);
177 for (size_t i = 0; i < colors.size(); ++i) 182 for (size_t i = 0; i < colors.size(); ++i)
178 context->deleteTexture(colors[i]); 183 context->deleteTexture(colors[i]);
179 return ok; 184 return ok;
180 } 185 }
181 186
182 } // namespace WebCore 187 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698