Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/html/canvas/WebGLQuery.h" | 7 #include "core/html/canvas/WebGLQuery.h" |
| 8 | 8 |
| 9 #include "core/html/canvas/WebGL2RenderingContextBase.h" | 9 #include "core/html/canvas/WebGL2RenderingContextBase.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // with or without Oilpan enabled. | 22 // with or without Oilpan enabled. |
| 23 // | 23 // |
| 24 // See comment in WebGLBuffer's destructor for additional | 24 // See comment in WebGLBuffer's destructor for additional |
| 25 // information on why this is done for WebGLSharedObject-derived | 25 // information on why this is done for WebGLSharedObject-derived |
| 26 // objects. | 26 // objects. |
| 27 detachAndDeleteObject(); | 27 detachAndDeleteObject(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 WebGLQuery::WebGLQuery(WebGL2RenderingContextBase* ctx) | 30 WebGLQuery::WebGLQuery(WebGL2RenderingContextBase* ctx) |
| 31 : WebGLSharedPlatform3DObject(ctx) | 31 : WebGLSharedPlatform3DObject(ctx) |
| 32 , m_target(0) | |
| 32 { | 33 { |
| 33 setObject(ctx->webContext()->createQueryEXT()); | 34 setObject(ctx->webContext()->createQueryEXT()); |
| 34 } | 35 } |
| 35 | 36 |
| 37 void WebGLQuery::setTarget(GLenum target) | |
| 38 { | |
| 39 if (!object() || !compatibleTarget(target)) | |
| 40 return; | |
|
Ken Russell (switch to Gerrit)
2015/06/24 21:07:22
These checks are supposed to be validated by the c
| |
| 41 | |
| 42 m_target = target; | |
| 43 } | |
| 44 | |
| 45 bool WebGLQuery::compatibleTarget(GLenum target) | |
| 46 { | |
| 47 if (!m_target) | |
| 48 return true; | |
| 49 | |
| 50 switch (target) { | |
| 51 // The SAMPLES_PASSED targets are interchangable. | |
| 52 case GL_ANY_SAMPLES_PASSED: | |
| 53 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: | |
| 54 return m_target == GL_ANY_SAMPLES_PASSED || m_target == GL_ANY_SAMPLES_P ASSED_CONSERVATIVE; | |
| 55 // Otherwise target is finalized the first time beginQuery() is called. | |
| 56 default: | |
| 57 return m_target == target; | |
| 58 } | |
| 59 } | |
| 60 | |
| 36 void WebGLQuery::deleteObjectImpl(WebGraphicsContext3D* context3d) | 61 void WebGLQuery::deleteObjectImpl(WebGraphicsContext3D* context3d) |
| 37 { | 62 { |
| 38 context3d->deleteQueryEXT(m_object); | 63 context3d->deleteQueryEXT(m_object); |
| 39 m_object = 0; | 64 m_object = 0; |
| 40 } | 65 } |
| 41 | 66 |
| 42 } // namespace blink | 67 } // namespace blink |
| OLD | NEW |