OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 5 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/string_split.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
17 #include "ui/gfx/gl/gl_bindings.h" | 18 #include "ui/gfx/gl/gl_bindings.h" |
18 #include "ui/gfx/gl/gl_bindings_skia_in_process.h" | 19 #include "ui/gfx/gl/gl_bindings_skia_in_process.h" |
19 #include "ui/gfx/gl/gl_context.h" | 20 #include "ui/gfx/gl/gl_context.h" |
20 #include "ui/gfx/gl/gl_implementation.h" | 21 #include "ui/gfx/gl/gl_implementation.h" |
21 #include "ui/gfx/gl/gl_surface.h" | 22 #include "ui/gfx/gl/gl_surface.h" |
22 | 23 |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 glGetShaderSource(shader, log_length, &returned_log_length, log.get()); | 1239 glGetShaderSource(shader, log_length, &returned_log_length, log.get()); |
1239 DCHECK(log_length == returned_log_length + 1); | 1240 DCHECK(log_length == returned_log_length + 1); |
1240 WebString res = WebString::fromUTF8(log.get(), returned_log_length); | 1241 WebString res = WebString::fromUTF8(log.get(), returned_log_length); |
1241 return res; | 1242 return res; |
1242 } | 1243 } |
1243 | 1244 |
1244 WebString WebGraphicsContext3DInProcessImpl::getString(WGC3Denum name) { | 1245 WebString WebGraphicsContext3DInProcessImpl::getString(WGC3Denum name) { |
1245 makeContextCurrent(); | 1246 makeContextCurrent(); |
1246 std::string result(reinterpret_cast<const char*>(glGetString(name))); | 1247 std::string result(reinterpret_cast<const char*>(glGetString(name))); |
1247 if (name == GL_EXTENSIONS) { | 1248 if (name == GL_EXTENSIONS) { |
1248 // GL_CHROMIUM_copy_texture_to_parent_texture requires the | 1249 if (!is_gles2_) { |
1249 // desktopGL-only function glGetTexLevelParameteriv (GLES2 | 1250 std::vector<std::string> split; |
1250 // doesn't support it). | 1251 base::SplitString(result, ' ', &split); |
1251 if (!is_gles2_) | 1252 if (std::find(split.begin(), split.end(), "GL_EXT_bgra") != split.end()) { |
| 1253 // If we support GL_EXT_bgra, pretend we support a couple of GLES2 |
| 1254 // extension that are a subset of it. |
| 1255 result += " GL_EXT_texture_format_BGRA8888 GL_EXT_read_format_bgra"; |
| 1256 } |
| 1257 // GL_CHROMIUM_copy_texture_to_parent_texture requires the |
| 1258 // desktopGL-only function glGetTexLevelParameteriv (GLES2 |
| 1259 // doesn't support it). |
1252 result += " GL_CHROMIUM_copy_texture_to_parent_texture"; | 1260 result += " GL_CHROMIUM_copy_texture_to_parent_texture"; |
| 1261 } |
1253 } | 1262 } |
1254 return WebString::fromUTF8(result.c_str()); | 1263 return WebString::fromUTF8(result.c_str()); |
1255 } | 1264 } |
1256 | 1265 |
1257 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv, | 1266 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv, |
1258 WGC3Denum, WGC3Denum, WGC3Dfloat*) | 1267 WGC3Denum, WGC3Denum, WGC3Dfloat*) |
1259 | 1268 |
1260 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv, | 1269 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv, |
1261 WGC3Denum, WGC3Denum, WGC3Dint*) | 1270 WGC3Denum, WGC3Denum, WGC3Dint*) |
1262 | 1271 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 if (length > 1) { | 1684 if (length > 1) { |
1676 entry->translated_source.reset(new char[length]); | 1685 entry->translated_source.reset(new char[length]); |
1677 ShGetObjectCode(compiler, entry->translated_source.get()); | 1686 ShGetObjectCode(compiler, entry->translated_source.get()); |
1678 } | 1687 } |
1679 entry->is_valid = true; | 1688 entry->is_valid = true; |
1680 return true; | 1689 return true; |
1681 } | 1690 } |
1682 | 1691 |
1683 } // namespace gpu | 1692 } // namespace gpu |
1684 } // namespace webkit | 1693 } // namespace webkit |
OLD | NEW |