| 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 <vector> | 10 #include <vector> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "gpu/command_buffer/service/framebuffer_manager.h" | 24 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 25 #include "gpu/command_buffer/service/gl_utils.h" | 25 #include "gpu/command_buffer/service/gl_utils.h" |
| 26 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 26 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 27 #include "gpu/command_buffer/service/id_manager.h" | 27 #include "gpu/command_buffer/service/id_manager.h" |
| 28 #include "gpu/command_buffer/service/program_manager.h" | 28 #include "gpu/command_buffer/service/program_manager.h" |
| 29 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 29 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 30 #include "gpu/command_buffer/service/shader_manager.h" | 30 #include "gpu/command_buffer/service/shader_manager.h" |
| 31 #include "gpu/command_buffer/service/texture_manager.h" | 31 #include "gpu/command_buffer/service/texture_manager.h" |
| 32 #if defined(UNIT_TEST) | 32 #if defined(UNIT_TEST) |
| 33 #elif defined(OS_LINUX) | 33 #elif defined(OS_LINUX) |
| 34 // XWindowWrapper is stubbed out for unit-tests. | 34 // GLXContextWrapper is stubbed out for unit-tests. |
| 35 #include "gpu/command_buffer/service/x_utils.h" | 35 #include "gpu/command_buffer/service/x_utils.h" |
| 36 #elif defined(OS_MACOSX) | 36 #elif defined(OS_MACOSX) |
| 37 #include "app/surface/accelerated_surface_mac.h" | 37 #include "app/surface/accelerated_surface_mac.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 #if !defined(GL_DEPTH24_STENCIL8) | 40 #if !defined(GL_DEPTH24_STENCIL8) |
| 41 #define GL_DEPTH24_STENCIL8 0x88F0 | 41 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 namespace gpu { | 44 namespace gpu { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 DISALLOW_COPY_AND_ASSIGN(FrameBuffer); | 253 DISALLOW_COPY_AND_ASSIGN(FrameBuffer); |
| 254 }; | 254 }; |
| 255 // } // anonymous namespace. | 255 // } // anonymous namespace. |
| 256 | 256 |
| 257 GLES2Decoder::GLES2Decoder(ContextGroup* group) | 257 GLES2Decoder::GLES2Decoder(ContextGroup* group) |
| 258 : group_(group), | 258 : group_(group), |
| 259 #if defined(UNIT_TEST) | 259 #if defined(UNIT_TEST) |
| 260 debug_(false) { | 260 debug_(false) { |
| 261 #elif defined(OS_LINUX) | 261 #elif defined(OS_LINUX) |
| 262 debug_(false), | 262 debug_(false), |
| 263 window_(NULL) { | 263 context_(NULL) { |
| 264 #elif defined(OS_WIN) | 264 #elif defined(OS_WIN) |
| 265 debug_(false), | 265 debug_(false), |
| 266 hwnd_(NULL) { | 266 hwnd_(NULL) { |
| 267 #else | 267 #else |
| 268 debug_(false) { | 268 debug_(false) { |
| 269 #endif | 269 #endif |
| 270 } | 270 } |
| 271 | 271 |
| 272 GLES2Decoder::~GLES2Decoder() { | 272 GLES2Decoder::~GLES2Decoder() { |
| 273 } | 273 } |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 ::wglGetCurrentContext() == gl_context_) { | 1536 ::wglGetCurrentContext() == gl_context_) { |
| 1537 return true; | 1537 return true; |
| 1538 } | 1538 } |
| 1539 if (!::wglMakeCurrent(gl_device_context_, gl_context_)) { | 1539 if (!::wglMakeCurrent(gl_device_context_, gl_context_)) { |
| 1540 DLOG(ERROR) << "Unable to make gl context current."; | 1540 DLOG(ERROR) << "Unable to make gl context current."; |
| 1541 return false; | 1541 return false; |
| 1542 } | 1542 } |
| 1543 return true; | 1543 return true; |
| 1544 #elif defined(OS_LINUX) | 1544 #elif defined(OS_LINUX) |
| 1545 // TODO(apatrick): offscreen rendering not yet supported on this platform. | 1545 // TODO(apatrick): offscreen rendering not yet supported on this platform. |
| 1546 return window()->MakeCurrent(); | 1546 return context()->MakeCurrent(); |
| 1547 #elif defined(OS_MACOSX) | 1547 #elif defined(OS_MACOSX) |
| 1548 if (gl_context_) { | 1548 if (gl_context_) { |
| 1549 if (CGLGetCurrentContext() != gl_context_) { | 1549 if (CGLGetCurrentContext() != gl_context_) { |
| 1550 if (CGLSetCurrentContext(gl_context_) != kCGLNoError) { | 1550 if (CGLSetCurrentContext(gl_context_) != kCGLNoError) { |
| 1551 DLOG(ERROR) << "Unable to make gl context current."; | 1551 DLOG(ERROR) << "Unable to make gl context current."; |
| 1552 return false; | 1552 return false; |
| 1553 } | 1553 } |
| 1554 } | 1554 } |
| 1555 return true; | 1555 return true; |
| 1556 } else { | 1556 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 for (GLsizei ii = 0; ii < n; ++ii) { | 1600 for (GLsizei ii = 0; ii < n; ++ii) { |
| 1601 if (id_manager()->GetServiceId(client_ids[ii], &service_ids[ii])) { | 1601 if (id_manager()->GetServiceId(client_ids[ii], &service_ids[ii])) { |
| 1602 id_manager()->RemoveMapping(client_ids[ii], service_ids[ii]); | 1602 id_manager()->RemoveMapping(client_ids[ii], service_ids[ii]); |
| 1603 } else { | 1603 } else { |
| 1604 service_ids[ii] = 0; | 1604 service_ids[ii] = 0; |
| 1605 } | 1605 } |
| 1606 } | 1606 } |
| 1607 } | 1607 } |
| 1608 | 1608 |
| 1609 bool GLES2DecoderImpl::InitPlatformSpecific() { | 1609 bool GLES2DecoderImpl::InitPlatformSpecific() { |
| 1610 #if !defined(UNIT_TEST) | 1610 #if !defined(UNIT_TEST) && !defined(OS_LINUX) |
| 1611 bool offscreen = pending_size_.width() > 0 && pending_size_.height() > 0; | 1611 bool offscreen = pending_size_.width() > 0 && pending_size_.height() > 0; |
| 1612 #endif | 1612 #endif |
| 1613 #if defined(UNIT_TEST) | 1613 #if defined(UNIT_TEST) |
| 1614 #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) | 1614 #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) |
| 1615 #elif defined(OS_WIN) | 1615 #elif defined(OS_WIN) |
| 1616 // Do one-off initialization. | 1616 // Do one-off initialization. |
| 1617 static bool success = InitializeOneOff(anti_aliased_); | 1617 static bool success = InitializeOneOff(anti_aliased_); |
| 1618 if (!success) | 1618 if (!success) |
| 1619 return false; | 1619 return false; |
| 1620 | 1620 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 | 1665 |
| 1666 if (parent_) { | 1666 if (parent_) { |
| 1667 if (!wglShareLists(parent_->gl_context_, gl_context_)) { | 1667 if (!wglShareLists(parent_->gl_context_, gl_context_)) { |
| 1668 DLOG(ERROR) << "Could not share GL contexts."; | 1668 DLOG(ERROR) << "Could not share GL contexts."; |
| 1669 DestroyPlatformSpecific(); | 1669 DestroyPlatformSpecific(); |
| 1670 return false; | 1670 return false; |
| 1671 } | 1671 } |
| 1672 } | 1672 } |
| 1673 | 1673 |
| 1674 #elif defined(OS_LINUX) | 1674 #elif defined(OS_LINUX) |
| 1675 // TODO(apatrick): offscreen rendering not yet supported on this platform. | |
| 1676 DCHECK(!offscreen); | |
| 1677 | |
| 1678 // TODO(apatrick): parent contexts not yet supported on this platform. | 1675 // TODO(apatrick): parent contexts not yet supported on this platform. |
| 1679 DCHECK(!parent_); | 1676 DCHECK(!parent_); |
| 1680 | 1677 |
| 1681 DCHECK(window()); | 1678 DCHECK(context()); |
| 1682 if (!window()->Initialize()) | 1679 |
| 1680 // Offscreen / onscreen handling done earlier on this platform (in |
| 1681 // GPUProcessor::Initialize). |
| 1682 |
| 1683 if (!context()->Initialize()) |
| 1683 return false; | 1684 return false; |
| 1684 #elif defined(OS_MACOSX) | 1685 #elif defined(OS_MACOSX) |
| 1685 // TODO(apatrick): parent contexts not yet supported on this platform. | 1686 // TODO(apatrick): parent contexts not yet supported on this platform. |
| 1686 DCHECK(!parent_); | 1687 DCHECK(!parent_); |
| 1687 | 1688 |
| 1688 if (offscreen) { | 1689 if (offscreen) { |
| 1689 // Create a 1x1 pbuffer and associated context to bootstrap things | 1690 // Create a 1x1 pbuffer and associated context to bootstrap things |
| 1690 static const CGLPixelFormatAttribute attribs[] = { | 1691 static const CGLPixelFormatAttribute attribs[] = { |
| 1691 (CGLPixelFormatAttribute) kCGLPFAPBuffer, | 1692 (CGLPixelFormatAttribute) kCGLPFAPBuffer, |
| 1692 (CGLPixelFormatAttribute) 0 | 1693 (CGLPixelFormatAttribute) 0 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 | 1965 |
| 1965 if (temporary_frame_buffer_.get()) | 1966 if (temporary_frame_buffer_.get()) |
| 1966 temporary_frame_buffer_->Destroy(); | 1967 temporary_frame_buffer_->Destroy(); |
| 1967 | 1968 |
| 1968 if (offscreen_saved_color_texture_.get()) | 1969 if (offscreen_saved_color_texture_.get()) |
| 1969 offscreen_saved_color_texture_->Destroy(); | 1970 offscreen_saved_color_texture_->Destroy(); |
| 1970 | 1971 |
| 1971 #if defined(UNIT_TEST) | 1972 #if defined(UNIT_TEST) |
| 1972 #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) | 1973 #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) |
| 1973 #elif defined(OS_LINUX) | 1974 #elif defined(OS_LINUX) |
| 1974 DCHECK(window()); | 1975 DCHECK(context()); |
| 1975 window()->Destroy(); | 1976 context()->Destroy(); |
| 1976 #elif defined(OS_MACOSX) | 1977 #elif defined(OS_MACOSX) |
| 1977 surface_.Destroy(); | 1978 surface_.Destroy(); |
| 1978 #endif | 1979 #endif |
| 1979 | 1980 |
| 1980 DestroyPlatformSpecific(); | 1981 DestroyPlatformSpecific(); |
| 1981 } | 1982 } |
| 1982 | 1983 |
| 1983 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { | 1984 void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| 1984 // We can't resize the render buffers immediately because there might be a | 1985 // We can't resize the render buffers immediately because there might be a |
| 1985 // partial frame rendered into them and we don't want the tail end of that | 1986 // partial frame rendered into them and we don't want the tail end of that |
| (...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3670 return error::kLostContext; | 3671 return error::kLostContext; |
| 3671 | 3672 |
| 3672 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); | 3673 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); |
| 3673 offscreen_saved_color_texture_->Copy(current_size_); | 3674 offscreen_saved_color_texture_->Copy(current_size_); |
| 3674 } else { | 3675 } else { |
| 3675 #if defined(UNIT_TEST) | 3676 #if defined(UNIT_TEST) |
| 3676 #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) | 3677 #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) |
| 3677 #elif defined(OS_WIN) | 3678 #elif defined(OS_WIN) |
| 3678 ::SwapBuffers(gl_device_context_); | 3679 ::SwapBuffers(gl_device_context_); |
| 3679 #elif defined(OS_LINUX) | 3680 #elif defined(OS_LINUX) |
| 3680 DCHECK(window()); | 3681 DCHECK(context()); |
| 3681 window()->SwapBuffers(); | 3682 context()->SwapBuffers(); |
| 3682 #elif defined(OS_MACOSX) | 3683 #elif defined(OS_MACOSX) |
| 3683 // TODO(kbr): Need to property hook up and track the OpenGL state and hook | 3684 // TODO(kbr): Need to property hook up and track the OpenGL state and hook |
| 3684 // up the notion of the currently bound FBO. | 3685 // up the notion of the currently bound FBO. |
| 3685 surface_.SwapBuffers(); | 3686 surface_.SwapBuffers(); |
| 3686 #endif | 3687 #endif |
| 3687 } | 3688 } |
| 3688 | 3689 |
| 3689 if (swap_buffers_callback_.get()) { | 3690 if (swap_buffers_callback_.get()) { |
| 3690 swap_buffers_callback_->Run(); | 3691 swap_buffers_callback_->Run(); |
| 3691 } | 3692 } |
| 3692 | 3693 |
| 3693 return error::kNoError; | 3694 return error::kNoError; |
| 3694 } | 3695 } |
| 3695 | 3696 |
| 3696 // Include the auto-generated part of this file. We split this because it means | 3697 // Include the auto-generated part of this file. We split this because it means |
| 3697 // we can easily edit the non-auto generated parts right here in this file | 3698 // we can easily edit the non-auto generated parts right here in this file |
| 3698 // instead of having to edit some template or the code generator. | 3699 // instead of having to edit some template or the code generator. |
| 3699 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 3700 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 3700 | 3701 |
| 3701 } // namespace gles2 | 3702 } // namespace gles2 |
| 3702 } // namespace gpu | 3703 } // namespace gpu |
| OLD | NEW |