OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2842 GPU_CLIENT_LOG_CODE_BLOCK({ | 2842 GPU_CLIENT_LOG_CODE_BLOCK({ |
2843 for (int32 i = 0; i < result->GetNumResults(); ++i) { | 2843 for (int32 i = 0; i < result->GetNumResults(); ++i) { |
2844 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 2844 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
2845 } | 2845 } |
2846 }); | 2846 }); |
2847 CheckGLError(); | 2847 CheckGLError(); |
2848 } | 2848 } |
2849 | 2849 |
2850 void GLES2Implementation::Swap() { | 2850 void GLES2Implementation::Swap() { |
2851 SwapBuffers(); | 2851 SwapBuffers(); |
2852 gpu_control_->Echo( | |
2853 base::Bind(&GLES2Implementation::OnSwapBuffersComplete, | |
2854 weak_ptr_factory_.GetWeakPtr())); | |
2855 } | 2852 } |
2856 | 2853 |
2857 void GLES2Implementation::PartialSwapBuffers(const gfx::Rect& sub_buffer) { | 2854 void GLES2Implementation::PartialSwapBuffers(const gfx::Rect& sub_buffer) { |
2858 PostSubBufferCHROMIUM(sub_buffer.x(), | 2855 PostSubBufferCHROMIUM( |
2859 sub_buffer.y(), | 2856 sub_buffer.x(), sub_buffer.y(), sub_buffer.width(), sub_buffer.height()); |
2860 sub_buffer.width(), | |
2861 sub_buffer.height()); | |
2862 gpu_control_->Echo(base::Bind(&GLES2Implementation::OnSwapBuffersComplete, | |
2863 weak_ptr_factory_.GetWeakPtr())); | |
2864 } | |
2865 | |
2866 void GLES2Implementation::SetSwapBuffersCompleteCallback( | |
2867 const base::Closure& swap_buffers_complete_callback) { | |
2868 swap_buffers_complete_callback_ = swap_buffers_complete_callback; | |
2869 } | 2857 } |
2870 | 2858 |
2871 static GLenum GetGLESOverlayTransform(gfx::OverlayTransform plane_transform) { | 2859 static GLenum GetGLESOverlayTransform(gfx::OverlayTransform plane_transform) { |
2872 switch (plane_transform) { | 2860 switch (plane_transform) { |
2873 case gfx::OVERLAY_TRANSFORM_INVALID: | 2861 case gfx::OVERLAY_TRANSFORM_INVALID: |
2874 break; | 2862 break; |
2875 case gfx::OVERLAY_TRANSFORM_NONE: | 2863 case gfx::OVERLAY_TRANSFORM_NONE: |
2876 return GL_OVERLAY_TRANSFORM_NONE_CHROMIUM; | 2864 return GL_OVERLAY_TRANSFORM_NONE_CHROMIUM; |
2877 case gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL: | 2865 case gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL: |
2878 return GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM; | 2866 return GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM; |
(...skipping 22 matching lines...) Expand all Loading... |
2901 display_bounds.x(), | 2889 display_bounds.x(), |
2902 display_bounds.y(), | 2890 display_bounds.y(), |
2903 display_bounds.width(), | 2891 display_bounds.width(), |
2904 display_bounds.height(), | 2892 display_bounds.height(), |
2905 uv_rect.x(), | 2893 uv_rect.x(), |
2906 uv_rect.y(), | 2894 uv_rect.y(), |
2907 uv_rect.width(), | 2895 uv_rect.width(), |
2908 uv_rect.height()); | 2896 uv_rect.height()); |
2909 } | 2897 } |
2910 | 2898 |
2911 void GLES2Implementation::OnSwapBuffersComplete() { | |
2912 if (!swap_buffers_complete_callback_.is_null()) | |
2913 swap_buffers_complete_callback_.Run(); | |
2914 } | |
2915 | |
2916 GLboolean GLES2Implementation::EnableFeatureCHROMIUM( | 2899 GLboolean GLES2Implementation::EnableFeatureCHROMIUM( |
2917 const char* feature) { | 2900 const char* feature) { |
2918 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2901 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2919 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glEnableFeatureCHROMIUM(" | 2902 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glEnableFeatureCHROMIUM(" |
2920 << feature << ")"); | 2903 << feature << ")"); |
2921 TRACE_EVENT0("gpu", "GLES2::EnableFeatureCHROMIUM"); | 2904 TRACE_EVENT0("gpu", "GLES2::EnableFeatureCHROMIUM"); |
2922 typedef cmds::EnableFeatureCHROMIUM::Result Result; | 2905 typedef cmds::EnableFeatureCHROMIUM::Result Result; |
2923 Result* result = GetResultAs<Result*>(); | 2906 Result* result = GetResultAs<Result*>(); |
2924 if (!result) { | 2907 if (!result) { |
2925 return false; | 2908 return false; |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 return true; | 4173 return true; |
4191 } | 4174 } |
4192 | 4175 |
4193 // Include the auto-generated part of this file. We split this because it means | 4176 // Include the auto-generated part of this file. We split this because it means |
4194 // we can easily edit the non-auto generated parts right here in this file | 4177 // we can easily edit the non-auto generated parts right here in this file |
4195 // instead of having to edit some template or the code generator. | 4178 // instead of having to edit some template or the code generator. |
4196 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4179 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
4197 | 4180 |
4198 } // namespace gles2 | 4181 } // namespace gles2 |
4199 } // namespace gpu | 4182 } // namespace gpu |
OLD | NEW |