| 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 #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 <cmath> | 10 #include <cmath> |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 QueryManager* GetQueryManager() override { return query_manager_.get(); } | 660 QueryManager* GetQueryManager() override { return query_manager_.get(); } |
| 661 VertexArrayManager* GetVertexArrayManager() override { | 661 VertexArrayManager* GetVertexArrayManager() override { |
| 662 return vertex_array_manager_.get(); | 662 return vertex_array_manager_.get(); |
| 663 } | 663 } |
| 664 ImageManager* GetImageManager() override { return image_manager_.get(); } | 664 ImageManager* GetImageManager() override { return image_manager_.get(); } |
| 665 | 665 |
| 666 ValuebufferManager* GetValuebufferManager() override { | 666 ValuebufferManager* GetValuebufferManager() override { |
| 667 return valuebuffer_manager(); | 667 return valuebuffer_manager(); |
| 668 } | 668 } |
| 669 | 669 |
| 670 bool ProcessPendingQueries(bool did_finish) override; | 670 bool HasPendingQueries() const override; |
| 671 void ProcessPendingQueries(bool did_finish) override; |
| 671 | 672 |
| 672 bool HasMoreIdleWork() override; | 673 bool HasMoreIdleWork() const override; |
| 673 void PerformIdleWork() override; | 674 void PerformIdleWork() override; |
| 674 | 675 |
| 675 void WaitForReadPixels(base::Closure callback) override; | 676 void WaitForReadPixels(base::Closure callback) override; |
| 676 | 677 |
| 677 void SetResizeCallback( | 678 void SetResizeCallback( |
| 678 const base::Callback<void(gfx::Size, float)>& callback) override; | 679 const base::Callback<void(gfx::Size, float)>& callback) override; |
| 679 | 680 |
| 680 Logger* GetLogger() override; | 681 Logger* GetLogger() override; |
| 681 | 682 |
| 682 void BeginDecoding() override; | 683 void BeginDecoding() override; |
| (...skipping 11569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12252 return true; | 12253 return true; |
| 12253 } | 12254 } |
| 12254 | 12255 |
| 12255 void GLES2DecoderImpl::DeleteQueriesEXTHelper( | 12256 void GLES2DecoderImpl::DeleteQueriesEXTHelper( |
| 12256 GLsizei n, const GLuint* client_ids) { | 12257 GLsizei n, const GLuint* client_ids) { |
| 12257 for (GLsizei ii = 0; ii < n; ++ii) { | 12258 for (GLsizei ii = 0; ii < n; ++ii) { |
| 12258 query_manager_->RemoveQuery(client_ids[ii]); | 12259 query_manager_->RemoveQuery(client_ids[ii]); |
| 12259 } | 12260 } |
| 12260 } | 12261 } |
| 12261 | 12262 |
| 12262 bool GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) { | 12263 bool GLES2DecoderImpl::HasPendingQueries() const { |
| 12263 if (query_manager_.get() == NULL) { | 12264 return query_manager_.get() && query_manager_->HavePendingQueries(); |
| 12264 return false; | 12265 } |
| 12265 } | 12266 |
| 12266 if (!query_manager_->ProcessPendingQueries(did_finish)) { | 12267 void GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) { |
| 12268 if (!query_manager_.get()) |
| 12269 return; |
| 12270 if (!query_manager_->ProcessPendingQueries(did_finish)) |
| 12267 current_decoder_error_ = error::kOutOfBounds; | 12271 current_decoder_error_ = error::kOutOfBounds; |
| 12268 } | |
| 12269 return query_manager_->HavePendingQueries(); | |
| 12270 } | 12272 } |
| 12271 | 12273 |
| 12272 // Note that if there are no pending readpixels right now, | 12274 // Note that if there are no pending readpixels right now, |
| 12273 // this function will call the callback immediately. | 12275 // this function will call the callback immediately. |
| 12274 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) { | 12276 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) { |
| 12275 if (features().use_async_readpixels && !pending_readpixel_fences_.empty()) { | 12277 if (features().use_async_readpixels && !pending_readpixel_fences_.empty()) { |
| 12276 pending_readpixel_fences_.back()->callbacks.push_back(callback); | 12278 pending_readpixel_fences_.back()->callbacks.push_back(callback); |
| 12277 } else { | 12279 } else { |
| 12278 callback.Run(); | 12280 callback.Run(); |
| 12279 } | 12281 } |
| 12280 } | 12282 } |
| 12281 | 12283 |
| 12282 void GLES2DecoderImpl::ProcessPendingReadPixels(bool did_finish) { | 12284 void GLES2DecoderImpl::ProcessPendingReadPixels(bool did_finish) { |
| 12283 // Note: |did_finish| guarantees that the GPU has passed the fence but | 12285 // Note: |did_finish| guarantees that the GPU has passed the fence but |
| 12284 // we cannot assume that GLFence::HasCompleted() will return true yet as | 12286 // we cannot assume that GLFence::HasCompleted() will return true yet as |
| 12285 // that's not guaranteed by all GLFence implementations. | 12287 // that's not guaranteed by all GLFence implementations. |
| 12286 while (!pending_readpixel_fences_.empty() && | 12288 while (!pending_readpixel_fences_.empty() && |
| 12287 (did_finish || | 12289 (did_finish || |
| 12288 pending_readpixel_fences_.front()->fence->HasCompleted())) { | 12290 pending_readpixel_fences_.front()->fence->HasCompleted())) { |
| 12289 std::vector<base::Closure> callbacks = | 12291 std::vector<base::Closure> callbacks = |
| 12290 pending_readpixel_fences_.front()->callbacks; | 12292 pending_readpixel_fences_.front()->callbacks; |
| 12291 pending_readpixel_fences_.pop(); | 12293 pending_readpixel_fences_.pop(); |
| 12292 for (size_t i = 0; i < callbacks.size(); i++) { | 12294 for (size_t i = 0; i < callbacks.size(); i++) { |
| 12293 callbacks[i].Run(); | 12295 callbacks[i].Run(); |
| 12294 } | 12296 } |
| 12295 } | 12297 } |
| 12296 } | 12298 } |
| 12297 | 12299 |
| 12298 bool GLES2DecoderImpl::HasMoreIdleWork() { | 12300 bool GLES2DecoderImpl::HasMoreIdleWork() const { |
| 12299 return !pending_readpixel_fences_.empty() || | 12301 return !pending_readpixel_fences_.empty() || |
| 12300 gpu_tracer_->HasTracesToProcess(); | 12302 gpu_tracer_->HasTracesToProcess(); |
| 12301 } | 12303 } |
| 12302 | 12304 |
| 12303 void GLES2DecoderImpl::PerformIdleWork() { | 12305 void GLES2DecoderImpl::PerformIdleWork() { |
| 12304 gpu_tracer_->ProcessTraces(); | 12306 gpu_tracer_->ProcessTraces(); |
| 12305 ProcessPendingReadPixels(false); | 12307 ProcessPendingReadPixels(false); |
| 12306 } | 12308 } |
| 12307 | 12309 |
| 12308 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32 immediate_data_size, | 12310 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32 immediate_data_size, |
| (...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15049 return error::kNoError; | 15051 return error::kNoError; |
| 15050 } | 15052 } |
| 15051 | 15053 |
| 15052 // Include the auto-generated part of this file. We split this because it means | 15054 // Include the auto-generated part of this file. We split this because it means |
| 15053 // we can easily edit the non-auto generated parts right here in this file | 15055 // we can easily edit the non-auto generated parts right here in this file |
| 15054 // instead of having to edit some template or the code generator. | 15056 // instead of having to edit some template or the code generator. |
| 15055 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15057 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15056 | 15058 |
| 15057 } // namespace gles2 | 15059 } // namespace gles2 |
| 15058 } // namespace gpu | 15060 } // namespace gpu |
| OLD | NEW |