Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GLStringQuery_h | |
| 6 #define GLStringQuery_h | |
| 7 | |
| 8 #include "gpu/command_buffer/client/gles2_interface.h" | |
| 9 #include "wtf/text/WTFString.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 // Performs a query for a string on GLES2Interface and returns a WTF::String. If | |
| 14 // it is unable to query the string, it wil return an empty WTF::String. | |
| 15 class GLStringQuery { | |
| 16 public: | |
| 17 struct ProgramInfoLog { | |
| 18 static void LengthFunction(gpu::gles2::GLES2Interface* gl, GLuint id, GL int* length) | |
| 19 { | |
| 20 return gl->GetProgramiv(id, GL_INFO_LOG_LENGTH, length); | |
| 21 } | |
| 22 static void LogFunction(gpu::gles2::GLES2Interface* gl, GLuint id, GLint length, GLint* returnedLength, LChar* ptr) | |
| 23 { | |
| 24 return gl->GetProgramInfoLog(id, length, returnedLength, reinterpret _cast<GLchar*>(ptr)); | |
| 25 } | |
| 26 }; | |
| 27 | |
| 28 struct ShaderInfoLog { | |
| 29 static void LengthFunction(gpu::gles2::GLES2Interface* gl, GLuint id, GL int* length) | |
| 30 { | |
| 31 gl->GetShaderiv(id, GL_INFO_LOG_LENGTH, length); | |
| 32 } | |
| 33 static void LogFunction(gpu::gles2::GLES2Interface* gl, GLuint id, GLint length, GLint* returnedLength, LChar* ptr) | |
| 34 { | |
| 35 gl->GetShaderInfoLog(id, length, returnedLength, reinterpret_cast<GL char*>(ptr)); | |
| 36 } | |
| 37 }; | |
| 38 | |
| 39 struct TranslatedShaderSourceANGLE { | |
| 40 static void LengthFunction(gpu::gles2::GLES2Interface* gl, GLuint id, GL int* length) | |
| 41 { | |
| 42 gl->GetShaderiv(id, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, length ); | |
| 43 } | |
| 44 static void LogFunction(gpu::gles2::GLES2Interface* gl, GLuint id, GLint length, GLint* returnedLength, LChar* ptr) | |
| 45 { | |
| 46 gl->GetTranslatedShaderSourceANGLE(id, length, returnedLength, reint erpret_cast<GLchar*>(ptr)); | |
| 47 } | |
| 48 }; | |
| 49 | |
| 50 GLStringQuery(gpu::gles2::GLES2Interface* gl) : m_gl(gl) {} | |
| 51 | |
| 52 template<class Traits> | |
| 53 WTF::String Run(GLuint id) { | |
| 54 GLint length = 0; | |
| 55 Traits::LengthFunction(m_gl, id, &length); | |
| 56 if (!length) | |
| 57 return WTF::emptyString(); | |
|
esprehn
2016/03/28 21:44:15
you don't need to write WTF:: on all these.
danakj
2016/03/28 21:45:34
Oh that stack of using's at the bottom of WTFStrin
| |
| 58 LChar* logPtr; | |
| 59 RefPtr<WTF::StringImpl> nameImpl = WTF::StringImpl::createUninitialized( length, logPtr); | |
|
esprehn
2016/03/28 21:44:15
ditto, don't write WTF::
| |
| 60 GLsizei returnedLength = 0; | |
| 61 Traits::LogFunction(m_gl, id, length, &returnedLength, logPtr); | |
| 62 // The returnedLength excludes the null terminator. If this check wasn't | |
| 63 // true, then we'd need to tell the returned String the real length. | |
| 64 DCHECK_EQ(returnedLength + 1, length); | |
| 65 return String(nameImpl.release()); | |
| 66 } | |
| 67 | |
| 68 private: | |
| 69 gpu::gles2::GLES2Interface* m_gl; | |
| 70 }; | |
| 71 | |
| 72 } // namespace blink | |
| 73 #endif // GLStringQuery_h | |
| OLD | NEW |