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

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

Issue 798233005: Merge 185069 "Enforce context refrence guards in WebGL extensions." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2214/
Patch Set: Created 6 years 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
« no previous file with comments | « Source/core/html/canvas/WebGLDebugShaders.cpp ('k') | Source/core/html/canvas/WebGLExtension.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 (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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 && satisfiesWebGLRequirements(context)); 56 && satisfiesWebGLRequirements(context));
57 } 57 }
58 58
59 const char* WebGLDrawBuffers::extensionName() 59 const char* WebGLDrawBuffers::extensionName()
60 { 60 {
61 return "WEBGL_draw_buffers"; 61 return "WEBGL_draw_buffers";
62 } 62 }
63 63
64 void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GLenum>& buffers) 64 void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GLenum>& buffers)
65 { 65 {
66 if (isLost()) 66 WebGLExtensionScopedContext scoped(this);
67 if (scoped.isLost())
67 return; 68 return;
68 GLsizei n = buffers.size(); 69 GLsizei n = buffers.size();
69 const GLenum* bufs = buffers.data(); 70 const GLenum* bufs = buffers.data();
70 if (!m_context->m_framebufferBinding) { 71 if (!scoped.context()->m_framebufferBinding) {
71 if (n != 1) { 72 if (n != 1) {
72 m_context->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", " more than one buffer"); 73 scoped.context()->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWE BGL", "more than one buffer");
73 return; 74 return;
74 } 75 }
75 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) { 76 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) {
76 m_context->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersWEBGL ", "BACK or NONE"); 77 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffe rsWEBGL", "BACK or NONE");
77 return; 78 return;
78 } 79 }
79 // Because the backbuffer is simulated on all current WebKit ports, we n eed to change BACK to COLOR_ATTACHMENT0. 80 // Because the backbuffer is simulated on all current WebKit ports, we n eed to change BACK to COLOR_ATTACHMENT0.
80 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE; 81 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE;
81 m_context->webContext()->drawBuffersEXT(1, &value); 82 scoped.context()->webContext()->drawBuffersEXT(1, &value);
82 m_context->setBackDrawBuffer(bufs[0]); 83 scoped.context()->setBackDrawBuffer(bufs[0]);
83 } else { 84 } else {
84 if (n > m_context->maxDrawBuffers()) { 85 if (n > scoped.context()->maxDrawBuffers()) {
85 m_context->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", " more than max draw buffers"); 86 scoped.context()->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWE BGL", "more than max draw buffers");
86 return; 87 return;
87 } 88 }
88 for (GLsizei i = 0; i < n; ++i) { 89 for (GLsizei i = 0; i < n; ++i) {
89 if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_AT TACHMENT0_EXT + i)) { 90 if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_AT TACHMENT0_EXT + i)) {
90 m_context->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersW EBGL", "COLOR_ATTACHMENTi_EXT or NONE"); 91 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawB uffersWEBGL", "COLOR_ATTACHMENTi_EXT or NONE");
91 return; 92 return;
92 } 93 }
93 } 94 }
94 m_context->m_framebufferBinding->drawBuffers(buffers); 95 scoped.context()->m_framebufferBinding->drawBuffers(buffers);
95 } 96 }
96 } 97 }
97 98
98 // static 99 // static
99 bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web glContext) 100 bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web glContext)
100 { 101 {
101 blink::WebGraphicsContext3D* context = webglContext->webContext(); 102 blink::WebGraphicsContext3D* context = webglContext->webContext();
102 Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil(); 103 Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil();
103 104
104 // This is called after we make sure GL_EXT_draw_buffers is supported. 105 // This is called after we make sure GL_EXT_draw_buffers is supported.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (supportsDepth) 171 if (supportsDepth)
171 context->deleteTexture(depth); 172 context->deleteTexture(depth);
172 if (supportsDepthStencil) 173 if (supportsDepthStencil)
173 context->deleteTexture(depthStencil); 174 context->deleteTexture(depthStencil);
174 for (size_t i = 0; i < colors.size(); ++i) 175 for (size_t i = 0; i < colors.size(); ++i)
175 context->deleteTexture(colors[i]); 176 context->deleteTexture(colors[i]);
176 return ok; 177 return ok;
177 } 178 }
178 179
179 } // namespace blink 180 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLDebugShaders.cpp ('k') | Source/core/html/canvas/WebGLExtension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698