| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "app/gfx/gl/gl_context.h" | 15 #include "app/gfx/gl/gl_context.h" |
| 16 #include "app/gfx/gl/gl_implementation.h" |
| 16 #include "base/callback.h" | 17 #include "base/callback.h" |
| 17 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
| 18 #include "base/weak_ptr.h" | 19 #include "base/weak_ptr.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 #define GLES2_GPU_SERVICE 1 | 21 #define GLES2_GPU_SERVICE 1 |
| 21 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 22 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 22 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 23 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 23 #include "gpu/command_buffer/common/id_allocator.h" | 24 #include "gpu/command_buffer/common/id_allocator.h" |
| 24 #include "gpu/command_buffer/service/buffer_manager.h" | 25 #include "gpu/command_buffer/service/buffer_manager.h" |
| 25 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 26 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 public: | 240 public: |
| 240 explicit FrameBuffer(GLES2DecoderImpl* decoder); | 241 explicit FrameBuffer(GLES2DecoderImpl* decoder); |
| 241 ~FrameBuffer(); | 242 ~FrameBuffer(); |
| 242 | 243 |
| 243 // Create a new frame buffer. | 244 // Create a new frame buffer. |
| 244 void Create(); | 245 void Create(); |
| 245 | 246 |
| 246 // Attach a color render buffer to a frame buffer. | 247 // Attach a color render buffer to a frame buffer. |
| 247 void AttachRenderTexture(Texture* texture); | 248 void AttachRenderTexture(Texture* texture); |
| 248 | 249 |
| 249 // Attach a depth stencil render buffer to a frame buffer. Note that | 250 // Attach a render buffer to a frame buffer. Note that this unbinds any |
| 250 // this unbinds any currently bound frame buffer. | 251 // currently bound frame buffer. |
| 251 void AttachDepthStencilRenderBuffer(RenderBuffer* render_buffer); | 252 void AttachRenderBuffer(GLenum target, RenderBuffer* render_buffer); |
| 252 | 253 |
| 253 // Clear the given attached buffers. | 254 // Clear the given attached buffers. |
| 254 void Clear(GLbitfield buffers); | 255 void Clear(GLbitfield buffers); |
| 255 | 256 |
| 256 // Destroy the frame buffer. This must be explicitly called before destroying | 257 // Destroy the frame buffer. This must be explicitly called before destroying |
| 257 // this object. | 258 // this object. |
| 258 void Destroy(); | 259 void Destroy(); |
| 259 | 260 |
| 260 // See glCheckFramebufferStatusEXT. | 261 // See glCheckFramebufferStatusEXT. |
| 261 GLenum CheckStatus(); | 262 GLenum CheckStatus(); |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 ProgramManager::ProgramInfo::Ref current_program_; | 1120 ProgramManager::ProgramInfo::Ref current_program_; |
| 1120 | 1121 |
| 1121 // The currently bound framebuffer | 1122 // The currently bound framebuffer |
| 1122 FramebufferManager::FramebufferInfo::Ref bound_framebuffer_; | 1123 FramebufferManager::FramebufferInfo::Ref bound_framebuffer_; |
| 1123 | 1124 |
| 1124 // The currently bound renderbuffer | 1125 // The currently bound renderbuffer |
| 1125 RenderbufferManager::RenderbufferInfo::Ref bound_renderbuffer_; | 1126 RenderbufferManager::RenderbufferInfo::Ref bound_renderbuffer_; |
| 1126 | 1127 |
| 1127 bool anti_aliased_; | 1128 bool anti_aliased_; |
| 1128 | 1129 |
| 1129 // The offscreen frame buffer that the client renders to. | 1130 // The offscreen frame buffer that the client renders to. With EGL, the |
| 1131 // depth and stencil buffers are separate. With regular GL there is a single |
| 1132 // packed depth stencil buffer in offscreen_target_depth_render_buffer_. |
| 1133 // offscreen_target_stencil_render_buffer_ is unused. |
| 1130 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; | 1134 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; |
| 1131 scoped_ptr<Texture> offscreen_target_color_texture_; | 1135 scoped_ptr<Texture> offscreen_target_color_texture_; |
| 1132 scoped_ptr<RenderBuffer> offscreen_target_depth_stencil_render_buffer_; | 1136 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; |
| 1137 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; |
| 1133 | 1138 |
| 1134 // The copy that is saved when SwapBuffers is called. | 1139 // The copy that is saved when SwapBuffers is called. |
| 1135 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1140 scoped_ptr<Texture> offscreen_saved_color_texture_; |
| 1136 | 1141 |
| 1137 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 1142 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
| 1138 | 1143 |
| 1139 // The last error message set. | 1144 // The last error message set. |
| 1140 std::string last_error_; | 1145 std::string last_error_; |
| 1141 | 1146 |
| 1142 bool use_shader_translator_; | 1147 bool use_shader_translator_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 | 1247 |
| 1243 bool Texture::AllocateStorage(const gfx::Size& size) { | 1248 bool Texture::AllocateStorage(const gfx::Size& size) { |
| 1244 DCHECK_NE(id_, 0u); | 1249 DCHECK_NE(id_, 0u); |
| 1245 ScopedGLErrorSuppressor suppressor(decoder_); | 1250 ScopedGLErrorSuppressor suppressor(decoder_); |
| 1246 ScopedTexture2DBinder binder(decoder_, id_); | 1251 ScopedTexture2DBinder binder(decoder_, id_); |
| 1247 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 1252 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1248 glTexParameteri( | 1253 glTexParameteri( |
| 1249 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 1254 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1250 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 1255 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1251 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 1256 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1252 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); | |
| 1253 | 1257 |
| 1254 glTexImage2D(GL_TEXTURE_2D, | 1258 glTexImage2D(GL_TEXTURE_2D, |
| 1255 0, // mip level | 1259 0, // mip level |
| 1256 GL_RGBA, | 1260 GL_RGBA, |
| 1257 size.width(), | 1261 size.width(), |
| 1258 size.height(), | 1262 size.height(), |
| 1259 0, // border | 1263 0, // border |
| 1260 GL_RGBA, | 1264 GL_RGBA, |
| 1261 GL_UNSIGNED_BYTE, | 1265 GL_UNSIGNED_BYTE, |
| 1262 NULL); | 1266 NULL); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 ScopedGLErrorSuppressor suppressor(decoder_); | 1350 ScopedGLErrorSuppressor suppressor(decoder_); |
| 1347 ScopedFrameBufferBinder binder(decoder_, id_); | 1351 ScopedFrameBufferBinder binder(decoder_, id_); |
| 1348 GLuint attach_id = texture ? texture->id() : 0; | 1352 GLuint attach_id = texture ? texture->id() : 0; |
| 1349 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, | 1353 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, |
| 1350 GL_COLOR_ATTACHMENT0, | 1354 GL_COLOR_ATTACHMENT0, |
| 1351 GL_TEXTURE_2D, | 1355 GL_TEXTURE_2D, |
| 1352 attach_id, | 1356 attach_id, |
| 1353 0); | 1357 0); |
| 1354 } | 1358 } |
| 1355 | 1359 |
| 1356 void FrameBuffer::AttachDepthStencilRenderBuffer(RenderBuffer* render_buffer) { | 1360 void FrameBuffer::AttachRenderBuffer(GLenum target, |
| 1361 RenderBuffer* render_buffer) { |
| 1357 DCHECK_NE(id_, 0u); | 1362 DCHECK_NE(id_, 0u); |
| 1358 ScopedGLErrorSuppressor suppressor(decoder_); | 1363 ScopedGLErrorSuppressor suppressor(decoder_); |
| 1359 ScopedFrameBufferBinder binder(decoder_, id_); | 1364 ScopedFrameBufferBinder binder(decoder_, id_); |
| 1360 GLuint attach_id = render_buffer ? render_buffer->id() : 0; | 1365 GLuint attach_id = render_buffer ? render_buffer->id() : 0; |
| 1361 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, | 1366 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, |
| 1362 GL_DEPTH_ATTACHMENT, | 1367 target, |
| 1363 GL_RENDERBUFFER, | |
| 1364 attach_id); | |
| 1365 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, | |
| 1366 GL_STENCIL_ATTACHMENT, | |
| 1367 GL_RENDERBUFFER, | 1368 GL_RENDERBUFFER, |
| 1368 attach_id); | 1369 attach_id); |
| 1369 } | 1370 } |
| 1370 | 1371 |
| 1371 void FrameBuffer::Clear(GLbitfield buffers) { | 1372 void FrameBuffer::Clear(GLbitfield buffers) { |
| 1372 ScopedGLErrorSuppressor suppressor(decoder_); | 1373 ScopedGLErrorSuppressor suppressor(decoder_); |
| 1373 ScopedFrameBufferBinder binder(decoder_, id_); | 1374 ScopedFrameBufferBinder binder(decoder_, id_); |
| 1374 glClear(buffers); | 1375 glClear(buffers); |
| 1375 } | 1376 } |
| 1376 | 1377 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1404 attrib_0_size_(0), | 1405 attrib_0_size_(0), |
| 1405 active_texture_unit_(0), | 1406 active_texture_unit_(0), |
| 1406 black_2d_texture_id_(0), | 1407 black_2d_texture_id_(0), |
| 1407 black_cube_texture_id_(0), | 1408 black_cube_texture_id_(0), |
| 1408 anti_aliased_(false), | 1409 anti_aliased_(false), |
| 1409 use_shader_translator_(true) { | 1410 use_shader_translator_(true) { |
| 1410 attrib_0_value_.v[0] = 0.0f; | 1411 attrib_0_value_.v[0] = 0.0f; |
| 1411 attrib_0_value_.v[1] = 0.0f; | 1412 attrib_0_value_.v[1] = 0.0f; |
| 1412 attrib_0_value_.v[2] = 0.0f; | 1413 attrib_0_value_.v[2] = 0.0f; |
| 1413 attrib_0_value_.v[3] = 1.0f; | 1414 attrib_0_value_.v[3] = 1.0f; |
| 1415 |
| 1416 // The shader translator is not needed for EGL because it already uses the |
| 1417 // GLSL ES syntax. It is translated for the unit tests because |
| 1418 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the empty |
| 1419 // string to CompileShader and this is not a valid shader. TODO(apatrick): |
| 1420 // fix this test. |
| 1421 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 || |
| 1422 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL) { |
| 1423 use_shader_translator_ = false; |
| 1424 } |
| 1414 } | 1425 } |
| 1415 | 1426 |
| 1416 bool GLES2DecoderImpl::Initialize(gfx::GLContext* context, | 1427 bool GLES2DecoderImpl::Initialize(gfx::GLContext* context, |
| 1417 const gfx::Size& size, | 1428 const gfx::Size& size, |
| 1418 GLES2Decoder* parent, | 1429 GLES2Decoder* parent, |
| 1419 uint32 parent_client_texture_id) { | 1430 uint32 parent_client_texture_id) { |
| 1420 DCHECK(context); | 1431 DCHECK(context); |
| 1421 DCHECK(!context_); | 1432 DCHECK(!context_); |
| 1422 context_ = context; | 1433 context_ = context; |
| 1423 | 1434 |
| 1424 // Create a GL context that is kept in a default state and shares a namespace | 1435 // Create a GL context that is kept in a default state and shares a namespace |
| 1425 // with the main GL context. | 1436 // with the main GL context. |
| 1426 default_context_.reset(gfx::GLContext::CreateOffscreenGLContext( | 1437 default_context_.reset(gfx::GLContext::CreateOffscreenGLContext(context_)); |
| 1427 context_->GetHandle())); | |
| 1428 if (!default_context_.get()) { | 1438 if (!default_context_.get()) { |
| 1429 Destroy(); | 1439 Destroy(); |
| 1430 return false; | 1440 return false; |
| 1431 } | 1441 } |
| 1432 | 1442 |
| 1433 // Keep only a weak pointer to the parent so we don't unmap its client | 1443 // Keep only a weak pointer to the parent so we don't unmap its client |
| 1434 // frame buffer after it has been destroyed. | 1444 // frame buffer after it has been destroyed. |
| 1435 if (parent) | 1445 if (parent) |
| 1436 parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr(); | 1446 parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr(); |
| 1437 | 1447 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 GL_UNSIGNED_BYTE, black); | 1486 GL_UNSIGNED_BYTE, black); |
| 1477 glBindTexture(GL_TEXTURE_2D, 0); | 1487 glBindTexture(GL_TEXTURE_2D, 0); |
| 1478 glBindTexture(GL_TEXTURE_CUBE_MAP, black_cube_texture_id_); | 1488 glBindTexture(GL_TEXTURE_CUBE_MAP, black_cube_texture_id_); |
| 1479 for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { | 1489 for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { |
| 1480 glTexImage2D(GLES2Util::IndexToGLFaceTarget(ii), 0, GL_RGBA, 1, 1, 0, | 1490 glTexImage2D(GLES2Util::IndexToGLFaceTarget(ii), 0, GL_RGBA, 1, 1, 0, |
| 1481 GL_RGBA, GL_UNSIGNED_BYTE, black); | 1491 GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 1482 } | 1492 } |
| 1483 glBindTexture(GL_TEXTURE_CUBE_MAP, 0); | 1493 glBindTexture(GL_TEXTURE_CUBE_MAP, 0); |
| 1484 CHECK_GL_ERROR(); | 1494 CHECK_GL_ERROR(); |
| 1485 | 1495 |
| 1486 #if !defined(UNIT_TEST) | |
| 1487 if (context_->IsOffscreen()) { | 1496 if (context_->IsOffscreen()) { |
| 1488 // Create the target frame buffer. This is the one that the client renders | 1497 // Create the target frame buffer. This is the one that the client renders |
| 1489 // directly to. | 1498 // directly to. |
| 1490 offscreen_target_frame_buffer_.reset(new FrameBuffer(this)); | 1499 offscreen_target_frame_buffer_.reset(new FrameBuffer(this)); |
| 1491 offscreen_target_frame_buffer_->Create(); | 1500 offscreen_target_frame_buffer_->Create(); |
| 1492 offscreen_target_color_texture_.reset(new Texture(this)); | 1501 offscreen_target_color_texture_.reset(new Texture(this)); |
| 1493 offscreen_target_color_texture_->Create(); | 1502 offscreen_target_color_texture_->Create(); |
| 1494 offscreen_target_depth_stencil_render_buffer_.reset( | 1503 offscreen_target_depth_render_buffer_.reset( |
| 1495 new RenderBuffer(this)); | 1504 new RenderBuffer(this)); |
| 1496 offscreen_target_depth_stencil_render_buffer_->Create(); | 1505 offscreen_target_depth_render_buffer_->Create(); |
| 1506 offscreen_target_stencil_render_buffer_.reset( |
| 1507 new RenderBuffer(this)); |
| 1508 offscreen_target_stencil_render_buffer_->Create(); |
| 1497 | 1509 |
| 1498 // Create the saved offscreen texture. The target frame buffer is copied | 1510 // Create the saved offscreen texture. The target frame buffer is copied |
| 1499 // here when SwapBuffers is called. | 1511 // here when SwapBuffers is called. |
| 1500 offscreen_saved_color_texture_.reset(new Texture(this)); | 1512 offscreen_saved_color_texture_.reset(new Texture(this)); |
| 1501 offscreen_saved_color_texture_->Create(); | 1513 offscreen_saved_color_texture_->Create(); |
| 1502 | 1514 |
| 1503 // Map the ID of the saved offscreen texture into the parent so that | 1515 // Map the ID of the saved offscreen texture into the parent so that |
| 1504 // it can reference it. | 1516 // it can reference it. |
| 1505 if (parent_) { | 1517 if (parent_) { |
| 1506 GLuint service_id = offscreen_saved_color_texture_->id(); | 1518 GLuint service_id = offscreen_saved_color_texture_->id(); |
| 1507 TextureManager::TextureInfo* info = | 1519 TextureManager::TextureInfo* info = |
| 1508 parent_->CreateTextureInfo(parent_client_texture_id, service_id); | 1520 parent_->CreateTextureInfo(parent_client_texture_id, service_id); |
| 1509 parent_->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D); | 1521 parent_->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D); |
| 1510 } | 1522 } |
| 1511 | 1523 |
| 1512 // Allocate the render buffers at their initial size and check the status | 1524 // Allocate the render buffers at their initial size and check the status |
| 1513 // of the frame buffers is okay. | 1525 // of the frame buffers is okay. |
| 1514 pending_offscreen_size_ = size; | 1526 pending_offscreen_size_ = size; |
| 1515 if (!UpdateOffscreenFrameBufferSize()) { | 1527 if (!UpdateOffscreenFrameBufferSize()) { |
| 1516 DLOG(ERROR) << "Could not allocate offscreen buffer storage."; | 1528 DLOG(ERROR) << "Could not allocate offscreen buffer storage."; |
| 1517 Destroy(); | 1529 Destroy(); |
| 1518 return false; | 1530 return false; |
| 1519 } | 1531 } |
| 1520 | 1532 |
| 1521 // Bind to the new default frame buffer (the offscreen target frame buffer). | 1533 // Bind to the new default frame buffer (the offscreen target frame buffer). |
| 1522 // This should now be associated with ID zero. | 1534 // This should now be associated with ID zero. |
| 1523 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 1535 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 1524 } | 1536 } |
| 1525 #endif // UNIT_TEST | |
| 1526 | 1537 |
| 1527 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) | |
| 1528 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 1538 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
| 1529 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 1539 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact |
| 1530 // isn't well documented; it was discovered in the Khronos OpenGL ES | 1540 // isn't well documented; it was discovered in the Khronos OpenGL ES |
| 1531 // mailing list archives. | 1541 // mailing list archives. |
| 1532 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 1542 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 1543 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
| 1544 } |
| 1533 | 1545 |
| 1534 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) && !defined(UNIT_TEST) | 1546 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) |
| 1535 // Initialize GLSL ES to GLSL translator. | 1547 // Initialize GLSL ES to GLSL translator. |
| 1536 if (!ShInitialize()) { | 1548 static bool glsl_translator_initialized = false; |
| 1537 DLOG(ERROR) << "Could not initialize GLSL translator."; | 1549 if (!glsl_translator_initialized) { |
| 1538 Destroy(); | 1550 if (!ShInitialize()) { |
| 1539 return false; | 1551 DLOG(ERROR) << "Could not initialize GLSL translator."; |
| 1552 Destroy(); |
| 1553 return false; |
| 1554 } |
| 1555 glsl_translator_initialized = true; |
| 1540 } | 1556 } |
| 1541 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER | 1557 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER |
| 1542 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 | |
| 1543 | 1558 |
| 1544 return true; | 1559 return true; |
| 1545 } | 1560 } |
| 1546 | 1561 |
| 1547 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { | 1562 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { |
| 1548 for (GLsizei ii = 0; ii < n; ++ii) { | 1563 for (GLsizei ii = 0; ii < n; ++ii) { |
| 1549 if (GetBufferInfo(client_ids[ii])) { | 1564 if (GetBufferInfo(client_ids[ii])) { |
| 1550 return false; | 1565 return false; |
| 1551 } | 1566 } |
| 1552 } | 1567 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 GLuint service_id = info->service_id(); | 1663 GLuint service_id = info->service_id(); |
| 1649 glDeleteTextures(1, &service_id); | 1664 glDeleteTextures(1, &service_id); |
| 1650 RemoveTextureInfo(client_ids[ii]); | 1665 RemoveTextureInfo(client_ids[ii]); |
| 1651 } | 1666 } |
| 1652 } | 1667 } |
| 1653 } | 1668 } |
| 1654 | 1669 |
| 1655 // } // anonymous namespace | 1670 // } // anonymous namespace |
| 1656 | 1671 |
| 1657 bool GLES2DecoderImpl::MakeCurrent() { | 1672 bool GLES2DecoderImpl::MakeCurrent() { |
| 1658 #if defined(UNIT_TEST) | |
| 1659 return true; | |
| 1660 #else | |
| 1661 return context_->MakeCurrent(); | 1673 return context_->MakeCurrent(); |
| 1662 #endif | |
| 1663 } | 1674 } |
| 1664 | 1675 |
| 1665 gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() { | 1676 gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() { |
| 1666 if (bound_framebuffer_ != 0) { | 1677 if (bound_framebuffer_ != 0) { |
| 1667 int width = 0; | 1678 int width = 0; |
| 1668 int height = 0; | 1679 int height = 0; |
| 1669 | 1680 |
| 1670 // Assume we have to have COLOR_ATTACHMENT0. Should we check for depth and | 1681 // Assume we have to have COLOR_ATTACHMENT0. Should we check for depth and |
| 1671 // stencil. | 1682 // stencil. |
| 1672 GLint fb_type = 0; | 1683 GLint fb_type = 0; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 } | 1742 } |
| 1732 default: | 1743 default: |
| 1733 // unknown so assume width and height are zero. | 1744 // unknown so assume width and height are zero. |
| 1734 break; | 1745 break; |
| 1735 } | 1746 } |
| 1736 | 1747 |
| 1737 return gfx::Size(width, height); | 1748 return gfx::Size(width, height); |
| 1738 } else if (offscreen_target_color_texture_.get()) { | 1749 } else if (offscreen_target_color_texture_.get()) { |
| 1739 return offscreen_target_color_texture_->size(); | 1750 return offscreen_target_color_texture_->size(); |
| 1740 } else { | 1751 } else { |
| 1741 #if defined(UNIT_TEST) | |
| 1742 return gfx::Size(INT_MAX, INT_MAX); | |
| 1743 #else | |
| 1744 return context_->GetSize(); | 1752 return context_->GetSize(); |
| 1745 #endif | |
| 1746 } | 1753 } |
| 1747 } | 1754 } |
| 1748 | 1755 |
| 1749 bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { | 1756 bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { |
| 1750 if (offscreen_target_color_texture_->size() == pending_offscreen_size_) | 1757 if (offscreen_target_color_texture_->size() == pending_offscreen_size_) |
| 1751 return true; | 1758 return true; |
| 1752 | 1759 |
| 1753 if (parent_) { | 1760 if (parent_) { |
| 1754 // Create the saved offscreen color texture (only accessible to parent). | 1761 // Create the saved offscreen color texture (only accessible to parent). |
| 1755 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); | 1762 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); |
| 1756 | 1763 |
| 1757 // Attach the saved offscreen color texture to a frame buffer so we can | 1764 // Attach the saved offscreen color texture to a frame buffer so we can |
| 1758 // clear it with glClear. | 1765 // clear it with glClear. |
| 1759 offscreen_target_frame_buffer_->AttachRenderTexture( | 1766 offscreen_target_frame_buffer_->AttachRenderTexture( |
| 1760 offscreen_saved_color_texture_.get()); | 1767 offscreen_saved_color_texture_.get()); |
| 1761 if (offscreen_target_frame_buffer_->CheckStatus() != | 1768 if (offscreen_target_frame_buffer_->CheckStatus() != |
| 1762 GL_FRAMEBUFFER_COMPLETE) { | 1769 GL_FRAMEBUFFER_COMPLETE) { |
| 1763 return false; | 1770 return false; |
| 1764 } | 1771 } |
| 1765 | 1772 |
| 1766 #if !defined(UNIT_TEST) | 1773 // TODO(apatrick): Fix this once ANGLE supports shared contexts. |
| 1767 // Clear the saved offscreen color texture. Use default GL context | 1774 // Clear the saved offscreen color texture. Use default GL context |
| 1768 // to ensure clear is not affected by client set state. | 1775 // to ensure clear is not affected by client set state. |
| 1769 { // NOLINT | 1776 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 1770 ScopedDefaultGLContext scoped_context(this); | 1777 ScopedDefaultGLContext scoped_context(this); |
| 1771 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, | 1778 glBindFramebufferEXT(GL_FRAMEBUFFER, |
| 1772 offscreen_target_frame_buffer_->id()); | 1779 offscreen_target_frame_buffer_->id()); |
| 1773 glClear(GL_COLOR_BUFFER_BIT); | 1780 glClear(GL_COLOR_BUFFER_BIT); |
| 1774 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | 1781 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
| 1775 | 1782 |
| 1776 if (glGetError() != GL_NO_ERROR) | 1783 if (glGetError() != GL_NO_ERROR) |
| 1777 return false; | 1784 return false; |
| 1778 } | 1785 } |
| 1779 #endif | |
| 1780 } | 1786 } |
| 1781 | 1787 |
| 1782 // Reallocate the offscreen target buffers. | 1788 // Reallocate the offscreen target buffers. |
| 1783 if (!offscreen_target_color_texture_->AllocateStorage( | 1789 if (!offscreen_target_color_texture_->AllocateStorage( |
| 1784 pending_offscreen_size_)) { | 1790 pending_offscreen_size_)) { |
| 1785 return false; | 1791 return false; |
| 1786 } | 1792 } |
| 1787 | 1793 |
| 1788 if (!offscreen_target_depth_stencil_render_buffer_->AllocateStorage( | 1794 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
| 1789 pending_offscreen_size_, GL_DEPTH24_STENCIL8)) { | 1795 // ANGLE only allows 16-bit depth buffers to be requested. As it happens, |
| 1790 return false; | 1796 // it creates a 24-bit depth buffer behind the scenes. |
| 1797 // TODO(apatrick): Attempt to use a packed 24/8 depth stencil buffer here if |
| 1798 // the extension is available. |
| 1799 if (!offscreen_target_depth_render_buffer_->AllocateStorage( |
| 1800 pending_offscreen_size_, GL_DEPTH_COMPONENT16)) { |
| 1801 return false; |
| 1802 } |
| 1803 |
| 1804 if (!offscreen_target_stencil_render_buffer_->AllocateStorage( |
| 1805 pending_offscreen_size_, GL_STENCIL_INDEX8)) { |
| 1806 return false; |
| 1807 } |
| 1808 } else { |
| 1809 if (!offscreen_target_depth_render_buffer_->AllocateStorage( |
| 1810 pending_offscreen_size_, GL_DEPTH24_STENCIL8)) { |
| 1811 return false; |
| 1812 } |
| 1791 } | 1813 } |
| 1792 | 1814 |
| 1793 // Attach the offscreen target buffers to the target frame buffer. | 1815 // Attach the offscreen target buffers to the target frame buffer. |
| 1794 offscreen_target_frame_buffer_->AttachRenderTexture( | 1816 offscreen_target_frame_buffer_->AttachRenderTexture( |
| 1795 offscreen_target_color_texture_.get()); | 1817 offscreen_target_color_texture_.get()); |
| 1796 offscreen_target_frame_buffer_->AttachDepthStencilRenderBuffer( | 1818 offscreen_target_frame_buffer_->AttachRenderBuffer( |
| 1797 offscreen_target_depth_stencil_render_buffer_.get()); | 1819 GL_DEPTH_ATTACHMENT, |
| 1820 offscreen_target_depth_render_buffer_.get()); |
| 1821 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
| 1822 offscreen_target_frame_buffer_->AttachRenderBuffer( |
| 1823 GL_STENCIL_ATTACHMENT, |
| 1824 offscreen_target_stencil_render_buffer_.get()); |
| 1825 } else { |
| 1826 offscreen_target_frame_buffer_->AttachRenderBuffer( |
| 1827 GL_STENCIL_ATTACHMENT, |
| 1828 offscreen_target_depth_render_buffer_.get()); |
| 1829 } |
| 1798 if (offscreen_target_frame_buffer_->CheckStatus() != | 1830 if (offscreen_target_frame_buffer_->CheckStatus() != |
| 1799 GL_FRAMEBUFFER_COMPLETE) { | 1831 GL_FRAMEBUFFER_COMPLETE) { |
| 1800 return false; | 1832 return false; |
| 1801 } | 1833 } |
| 1802 | 1834 |
| 1803 #if !defined(UNIT_TEST) | 1835 // TODO(apatrick): Fix this once ANGLE supports shared contexts. |
| 1804 // Clear offscreen frame buffer to its initial state. Use default GL context | 1836 // Clear offscreen frame buffer to its initial state. Use default GL context |
| 1805 // to ensure clear is not affected by client set state. | 1837 // to ensure clear is not affected by client set state. |
| 1806 { // NOLINT | 1838 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 1807 ScopedDefaultGLContext scoped_context(this); | 1839 ScopedDefaultGLContext scoped_context(this); |
| 1808 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, | 1840 glBindFramebufferEXT(GL_FRAMEBUFFER, |
| 1809 offscreen_target_frame_buffer_->id()); | 1841 offscreen_target_frame_buffer_->id()); |
| 1810 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 1842 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 1811 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | 1843 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
| 1812 | 1844 |
| 1813 if (glGetError() != GL_NO_ERROR) | 1845 if (glGetError() != GL_NO_ERROR) |
| 1814 return false; | 1846 return false; |
| 1815 } | 1847 } |
| 1816 #endif | |
| 1817 | 1848 |
| 1818 if (parent_) { | 1849 if (parent_) { |
| 1819 // Create the saved offscreen color texture (only accessible to parent). | 1850 // Create the saved offscreen color texture (only accessible to parent). |
| 1820 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); | 1851 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); |
| 1821 | 1852 |
| 1822 // Update the info about the offscreen saved color texture in the parent. | 1853 // Update the info about the offscreen saved color texture in the parent. |
| 1823 // The reference to the parent is a weak pointer and will become null if the | 1854 // The reference to the parent is a weak pointer and will become null if the |
| 1824 // parent is later destroyed. | 1855 // parent is later destroyed. |
| 1825 GLuint service_id = offscreen_saved_color_texture_->id(); | 1856 GLuint service_id = offscreen_saved_color_texture_->id(); |
| 1826 | 1857 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 if (offscreen_target_frame_buffer_.get()) { | 1909 if (offscreen_target_frame_buffer_.get()) { |
| 1879 offscreen_target_frame_buffer_->Destroy(); | 1910 offscreen_target_frame_buffer_->Destroy(); |
| 1880 offscreen_target_frame_buffer_.reset(); | 1911 offscreen_target_frame_buffer_.reset(); |
| 1881 } | 1912 } |
| 1882 | 1913 |
| 1883 if (offscreen_target_color_texture_.get()) { | 1914 if (offscreen_target_color_texture_.get()) { |
| 1884 offscreen_target_color_texture_->Destroy(); | 1915 offscreen_target_color_texture_->Destroy(); |
| 1885 offscreen_target_color_texture_.reset(); | 1916 offscreen_target_color_texture_.reset(); |
| 1886 } | 1917 } |
| 1887 | 1918 |
| 1888 if (offscreen_target_depth_stencil_render_buffer_.get()) { | 1919 if (offscreen_target_depth_render_buffer_.get()) { |
| 1889 offscreen_target_depth_stencil_render_buffer_->Destroy(); | 1920 offscreen_target_depth_render_buffer_->Destroy(); |
| 1890 offscreen_target_depth_stencil_render_buffer_.reset(); | 1921 offscreen_target_depth_render_buffer_.reset(); |
| 1922 } |
| 1923 |
| 1924 if (offscreen_target_stencil_render_buffer_.get()) { |
| 1925 offscreen_target_stencil_render_buffer_->Destroy(); |
| 1926 offscreen_target_stencil_render_buffer_.reset(); |
| 1891 } | 1927 } |
| 1892 | 1928 |
| 1893 if (offscreen_saved_color_texture_.get()) { | 1929 if (offscreen_saved_color_texture_.get()) { |
| 1894 offscreen_saved_color_texture_->Destroy(); | 1930 offscreen_saved_color_texture_->Destroy(); |
| 1895 offscreen_saved_color_texture_.reset(); | 1931 offscreen_saved_color_texture_.reset(); |
| 1896 } | 1932 } |
| 1897 } | 1933 } |
| 1898 | 1934 |
| 1899 if (default_context_.get()) { | 1935 if (default_context_.get()) { |
| 1900 default_context_->Destroy(); | 1936 default_context_->Destroy(); |
| 1901 default_context_.reset(); | 1937 default_context_.reset(); |
| 1902 } | 1938 } |
| 1903 | |
| 1904 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST) | |
| 1905 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) | |
| 1906 // Terminate GLSL translator. | |
| 1907 ShFinalize(); | |
| 1908 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER | |
| 1909 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 | |
| 1910 } | 1939 } |
| 1911 | 1940 |
| 1912 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { | 1941 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| 1913 // We can't resize the render buffers immediately because there might be a | 1942 // We can't resize the render buffers immediately because there might be a |
| 1914 // partial frame rendered into them and we don't want the tail end of that | 1943 // partial frame rendered into them and we don't want the tail end of that |
| 1915 // rendered into the reallocated storage. Defer until the next SwapBuffers. | 1944 // rendered into the reallocated storage. Defer until the next SwapBuffers. |
| 1916 pending_offscreen_size_ = size; | 1945 pending_offscreen_size_ = size; |
| 1917 } | 1946 } |
| 1918 | 1947 |
| 1919 const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const { | 1948 const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2169 SetGLError(GL_INVALID_OPERATION, | 2198 SetGLError(GL_INVALID_OPERATION, |
| 2170 "glGenerateMipmaps: Can not generate mips for npot textures"); | 2199 "glGenerateMipmaps: Can not generate mips for npot textures"); |
| 2171 return; | 2200 return; |
| 2172 } | 2201 } |
| 2173 glGenerateMipmapEXT(target); | 2202 glGenerateMipmapEXT(target); |
| 2174 } | 2203 } |
| 2175 | 2204 |
| 2176 bool GLES2DecoderImpl::GetHelper( | 2205 bool GLES2DecoderImpl::GetHelper( |
| 2177 GLenum pname, GLint* params, GLsizei* num_written) { | 2206 GLenum pname, GLint* params, GLsizei* num_written) { |
| 2178 DCHECK(num_written); | 2207 DCHECK(num_written); |
| 2179 switch (pname) { | 2208 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 2180 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) | 2209 switch (pname) { |
| 2181 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: | 2210 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 2182 *num_written = 1; | 2211 *num_written = 1; |
| 2183 if (params) { | 2212 if (params) { |
| 2184 *params = GL_RGBA; // TODO(gman): get correct format. | 2213 *params = GL_RGBA; // TODO(gman): get correct format. |
| 2185 } | 2214 } |
| 2186 return true; | 2215 return true; |
| 2187 case GL_IMPLEMENTATION_COLOR_READ_TYPE: | 2216 case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 2188 *num_written = 1; | 2217 *num_written = 1; |
| 2189 if (params) { | 2218 if (params) { |
| 2190 *params = GL_UNSIGNED_BYTE; // TODO(gman): get correct type. | 2219 *params = GL_UNSIGNED_BYTE; // TODO(gman): get correct type. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2201 if (params) { | 2230 if (params) { |
| 2202 *params = group_->max_varying_vectors(); | 2231 *params = group_->max_varying_vectors(); |
| 2203 } | 2232 } |
| 2204 return true; | 2233 return true; |
| 2205 case GL_MAX_VERTEX_UNIFORM_VECTORS: | 2234 case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 2206 *num_written = 1; | 2235 *num_written = 1; |
| 2207 if (params) { | 2236 if (params) { |
| 2208 *params = group_->max_vertex_uniform_vectors(); | 2237 *params = group_->max_vertex_uniform_vectors(); |
| 2209 } | 2238 } |
| 2210 return true; | 2239 return true; |
| 2211 #endif | 2240 } |
| 2241 } |
| 2242 switch (pname) { |
| 2212 case GL_COMPRESSED_TEXTURE_FORMATS: | 2243 case GL_COMPRESSED_TEXTURE_FORMATS: |
| 2213 *num_written = 0; | 2244 *num_written = 0; |
| 2214 // We don't support compressed textures. | 2245 // We don't support compressed textures. |
| 2215 return true; | 2246 return true; |
| 2216 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: | 2247 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 2217 *num_written = 1; | 2248 *num_written = 1; |
| 2218 if (params) { | 2249 if (params) { |
| 2219 *params = 0; // We don't support compressed textures. | 2250 *params = 0; // We don't support compressed textures. |
| 2220 } | 2251 } |
| 2221 return true; | 2252 return true; |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 | 3256 |
| 3226 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { | 3257 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { |
| 3227 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 3258 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 3228 client_id, "glCompileShader"); | 3259 client_id, "glCompileShader"); |
| 3229 if (!info) { | 3260 if (!info) { |
| 3230 return; | 3261 return; |
| 3231 } | 3262 } |
| 3232 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to | 3263 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to |
| 3233 // glShaderSource and then glCompileShader. | 3264 // glShaderSource and then glCompileShader. |
| 3234 const char* shader_src = info->source().c_str(); | 3265 const char* shader_src = info->source().c_str(); |
| 3235 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST) | |
| 3236 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) | 3266 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) |
| 3237 ShHandle compiler = 0; | 3267 ShHandle compiler = 0; |
| 3238 if (use_shader_translator_) { | 3268 if (use_shader_translator_) { |
| 3239 int dbg_options = 0; | 3269 int dbg_options = 0; |
| 3240 EShLanguage language = info->shader_type() == GL_VERTEX_SHADER ? | 3270 EShLanguage language = info->shader_type() == GL_VERTEX_SHADER ? |
| 3241 EShLangVertex : EShLangFragment; | 3271 EShLangVertex : EShLangFragment; |
| 3242 TBuiltInResource resources; | 3272 TBuiltInResource resources; |
| 3243 resources.maxVertexAttribs = group_->max_vertex_attribs(); | 3273 resources.maxVertexAttribs = group_->max_vertex_attribs(); |
| 3244 resources.maxVertexUniformVectors = | 3274 resources.maxVertexUniformVectors = |
| 3245 group_->max_vertex_uniform_vectors(); | 3275 group_->max_vertex_uniform_vectors(); |
| 3246 resources.maxVaryingVectors = group_->max_varying_vectors(); | 3276 resources.maxVaryingVectors = group_->max_varying_vectors(); |
| 3247 resources.maxVertexTextureImageUnits = | 3277 resources.maxVertexTextureImageUnits = |
| 3248 group_->max_vertex_texture_image_units(); | 3278 group_->max_vertex_texture_image_units(); |
| 3249 resources.maxCombinedTextureImageUnits = group_->max_texture_units(); | 3279 resources.maxCombinedTextureImageUnits = group_->max_texture_units(); |
| 3250 resources.maxTextureImageUnits = group_->max_texture_image_units(); | 3280 resources.maxTextureImageUnits = group_->max_texture_image_units(); |
| 3251 resources.maxFragmentUniformVectors = | 3281 resources.maxFragmentUniformVectors = |
| 3252 group_->max_fragment_uniform_vectors(); | 3282 group_->max_fragment_uniform_vectors(); |
| 3253 resources.maxDrawBuffers = 1; | 3283 resources.maxDrawBuffers = 1; |
| 3254 compiler = ShConstructCompiler(language, dbg_options); | 3284 compiler = ShConstructCompiler(language, dbg_options); |
| 3255 if (!ShCompile(compiler, &shader_src, 1, EShOptNone, &resources, | 3285 if (!ShCompile(compiler, &shader_src, 1, EShOptNone, &resources, |
| 3256 dbg_options)) { | 3286 dbg_options)) { |
| 3257 info->SetTranslationStatus(false, ShGetInfoLog(compiler)); | 3287 info->SetTranslationStatus(false, ShGetInfoLog(compiler)); |
| 3258 ShDestruct(compiler); | 3288 ShDestruct(compiler); |
| 3259 return; | 3289 return; |
| 3260 } | 3290 } |
| 3291 |
| 3261 info->SetTranslationStatus(true, ""); | 3292 info->SetTranslationStatus(true, ""); |
| 3262 shader_src = ShGetObjectCode(compiler); | 3293 shader_src = ShGetObjectCode(compiler); |
| 3263 } | 3294 } |
| 3264 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER | 3295 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER |
| 3265 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 | |
| 3266 | 3296 |
| 3267 glShaderSource(info->service_id(), 1, &shader_src, NULL); | 3297 glShaderSource(info->service_id(), 1, &shader_src, NULL); |
| 3268 glCompileShader(info->service_id()); | 3298 glCompileShader(info->service_id()); |
| 3269 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST) | |
| 3270 #ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER | 3299 #ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER |
| 3271 if (use_shader_translator_) { | 3300 if (use_shader_translator_) { |
| 3272 ShDestruct(compiler); | 3301 ShDestruct(compiler); |
| 3273 } | 3302 } |
| 3274 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER | 3303 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER |
| 3275 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 | |
| 3276 }; | 3304 }; |
| 3277 | 3305 |
| 3278 void GLES2DecoderImpl::DoGetShaderiv( | 3306 void GLES2DecoderImpl::DoGetShaderiv( |
| 3279 GLuint shader, GLenum pname, GLint* params) { | 3307 GLuint shader, GLenum pname, GLint* params) { |
| 3280 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 3308 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 3281 shader, "glGetShaderiv"); | 3309 shader, "glGetShaderiv"); |
| 3282 if (!info) { | 3310 if (!info) { |
| 3283 return; | 3311 return; |
| 3284 } | 3312 } |
| 3285 switch (pname) { | 3313 switch (pname) { |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4002 default: | 4030 default: |
| 4003 str = gl_str; | 4031 str = gl_str; |
| 4004 break; | 4032 break; |
| 4005 } | 4033 } |
| 4006 Bucket* bucket = CreateBucket(c.bucket_id); | 4034 Bucket* bucket = CreateBucket(c.bucket_id); |
| 4007 bucket->SetFromString(str); | 4035 bucket->SetFromString(str); |
| 4008 return error::kNoError; | 4036 return error::kNoError; |
| 4009 } | 4037 } |
| 4010 | 4038 |
| 4011 void GLES2DecoderImpl::DoBufferData( | 4039 void GLES2DecoderImpl::DoBufferData( |
| 4012 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) { | 4040 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) { |
| 4013 if (!ValidateGLenumBufferTarget(target)) { | 4041 if (!ValidateGLenumBufferTarget(target)) { |
| 4014 SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM"); | 4042 SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM"); |
| 4015 return; | 4043 return; |
| 4016 } | 4044 } |
| 4017 if (!ValidateGLenumBufferUsage(usage)) { | 4045 if (!ValidateGLenumBufferUsage(usage)) { |
| 4018 SetGLError(GL_INVALID_ENUM, "glBufferData: usage GL_INVALID_ENUM"); | 4046 SetGLError(GL_INVALID_ENUM, "glBufferData: usage GL_INVALID_ENUM"); |
| 4019 return; | 4047 return; |
| 4020 } | 4048 } |
| 4021 if (size < 0) { | 4049 if (size < 0) { |
| 4022 SetGLError(GL_INVALID_VALUE, "glBufferData: size < 0"); | 4050 SetGLError(GL_INVALID_VALUE, "glBufferData: size < 0"); |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4667 | 4695 |
| 4668 // First check to see if a deferred offscreen render buffer resize is | 4696 // First check to see if a deferred offscreen render buffer resize is |
| 4669 // pending. | 4697 // pending. |
| 4670 if (!UpdateOffscreenFrameBufferSize()) | 4698 if (!UpdateOffscreenFrameBufferSize()) |
| 4671 return error::kLostContext; | 4699 return error::kLostContext; |
| 4672 | 4700 |
| 4673 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); | 4701 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); |
| 4674 offscreen_saved_color_texture_->Copy( | 4702 offscreen_saved_color_texture_->Copy( |
| 4675 offscreen_saved_color_texture_->size()); | 4703 offscreen_saved_color_texture_->size()); |
| 4676 } else { | 4704 } else { |
| 4677 #if !defined(UNIT_TEST) | |
| 4678 context_->SwapBuffers(); | 4705 context_->SwapBuffers(); |
| 4679 #endif | |
| 4680 } | 4706 } |
| 4681 | 4707 |
| 4682 // TODO(kbr): when the back buffer is multisampled, then at least on Mac | 4708 // TODO(kbr): when the back buffer is multisampled, then at least on Mac |
| 4683 // OS X (and probably on all platforms, for best semantics), we will need | 4709 // OS X (and probably on all platforms, for best semantics), we will need |
| 4684 // to perform the resolve step and bind the offscreen_saved_color_texture_ | 4710 // to perform the resolve step and bind the offscreen_saved_color_texture_ |
| 4685 // as the color attachment before calling the swap buffers callback, which | 4711 // as the color attachment before calling the swap buffers callback, which |
| 4686 // expects a normal (non-multisampled) frame buffer for glCopyTexImage2D / | 4712 // expects a normal (non-multisampled) frame buffer for glCopyTexImage2D / |
| 4687 // glReadPixels. After the callback runs, the multisampled frame buffer | 4713 // glReadPixels. After the callback runs, the multisampled frame buffer |
| 4688 // needs to be bound again. | 4714 // needs to be bound again. |
| 4689 | 4715 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4725 return error::kNoError; | 4751 return error::kNoError; |
| 4726 } | 4752 } |
| 4727 | 4753 |
| 4728 // Include the auto-generated part of this file. We split this because it means | 4754 // Include the auto-generated part of this file. We split this because it means |
| 4729 // we can easily edit the non-auto generated parts right here in this file | 4755 // we can easily edit the non-auto generated parts right here in this file |
| 4730 // instead of having to edit some template or the code generator. | 4756 // instead of having to edit some template or the code generator. |
| 4731 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 4757 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 4732 | 4758 |
| 4733 } // namespace gles2 | 4759 } // namespace gles2 |
| 4734 } // namespace gpu | 4760 } // namespace gpu |
| OLD | NEW |