Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: gpu/command_buffer/service/query_manager.cc

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/query_manager.h" 5 #include "gpu/command_buffer/service/query_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 bool QueryCounter(base::subtle::Atomic32 submit_count) override; 472 bool QueryCounter(base::subtle::Atomic32 submit_count) override;
473 void Pause() override; 473 void Pause() override;
474 void Resume() override; 474 void Resume() override;
475 bool Process(bool did_finish) override; 475 bool Process(bool did_finish) override;
476 void Destroy(bool have_context) override; 476 void Destroy(bool have_context) override;
477 477
478 protected: 478 protected:
479 ~CommandsCompletedQuery() override; 479 ~CommandsCompletedQuery() override;
480 480
481 private: 481 private:
482 std::unique_ptr<gfx::GLFence> fence_; 482 std::unique_ptr<gl::GLFence> fence_;
483 base::TimeTicks begin_time_; 483 base::TimeTicks begin_time_;
484 }; 484 };
485 485
486 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager, 486 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager,
487 GLenum target, 487 GLenum target,
488 int32_t shm_id, 488 int32_t shm_id,
489 uint32_t shm_offset) 489 uint32_t shm_offset)
490 : Query(manager, target, shm_id, shm_offset) {} 490 : Query(manager, target, shm_id, shm_offset) {}
491 491
492 bool CommandsCompletedQuery::Begin() { 492 bool CommandsCompletedQuery::Begin() {
493 MarkAsActive(); 493 MarkAsActive();
494 begin_time_ = base::TimeTicks::Now(); 494 begin_time_ = base::TimeTicks::Now();
495 return true; 495 return true;
496 } 496 }
497 497
498 void CommandsCompletedQuery::Pause() { 498 void CommandsCompletedQuery::Pause() {
499 MarkAsPaused(); 499 MarkAsPaused();
500 } 500 }
501 501
502 void CommandsCompletedQuery::Resume() { 502 void CommandsCompletedQuery::Resume() {
503 MarkAsActive(); 503 MarkAsActive();
504 } 504 }
505 505
506 bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) { 506 bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) {
507 if (fence_ && fence_->ResetSupported()) { 507 if (fence_ && fence_->ResetSupported()) {
508 fence_->ResetState(); 508 fence_->ResetState();
509 } 509 }
510 else { 510 else {
511 fence_.reset(gfx::GLFence::Create()); 511 fence_.reset(gl::GLFence::Create());
512 } 512 }
513 DCHECK(fence_); 513 DCHECK(fence_);
514 return AddToPendingQueue(submit_count); 514 return AddToPendingQueue(submit_count);
515 } 515 }
516 516
517 bool CommandsCompletedQuery::QueryCounter(base::subtle::Atomic32 submit_count) { 517 bool CommandsCompletedQuery::QueryCounter(base::subtle::Atomic32 submit_count) {
518 NOTREACHED(); 518 NOTREACHED();
519 return false; 519 return false;
520 } 520 }
521 521
(...skipping 30 matching lines...) Expand all
552 bool QueryCounter(base::subtle::Atomic32 submit_count) override; 552 bool QueryCounter(base::subtle::Atomic32 submit_count) override;
553 void Pause() override; 553 void Pause() override;
554 void Resume() override; 554 void Resume() override;
555 bool Process(bool did_finish) override; 555 bool Process(bool did_finish) override;
556 void Destroy(bool have_context) override; 556 void Destroy(bool have_context) override;
557 557
558 protected: 558 protected:
559 ~TimeElapsedQuery() override; 559 ~TimeElapsedQuery() override;
560 560
561 private: 561 private:
562 std::unique_ptr<gfx::GPUTimer> gpu_timer_; 562 std::unique_ptr<gl::GPUTimer> gpu_timer_;
563 }; 563 };
564 564
565 TimeElapsedQuery::TimeElapsedQuery(QueryManager* manager, 565 TimeElapsedQuery::TimeElapsedQuery(QueryManager* manager,
566 GLenum target, 566 GLenum target,
567 int32_t shm_id, 567 int32_t shm_id,
568 uint32_t shm_offset) 568 uint32_t shm_offset)
569 : Query(manager, target, shm_id, shm_offset), 569 : Query(manager, target, shm_id, shm_offset),
570 gpu_timer_(manager->CreateGPUTimer(true)) {} 570 gpu_timer_(manager->CreateGPUTimer(true)) {}
571 571
572 bool TimeElapsedQuery::Begin() { 572 bool TimeElapsedQuery::Begin() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 bool QueryCounter(base::subtle::Atomic32 submit_count) override; 629 bool QueryCounter(base::subtle::Atomic32 submit_count) override;
630 void Pause() override; 630 void Pause() override;
631 void Resume() override; 631 void Resume() override;
632 bool Process(bool did_finish) override; 632 bool Process(bool did_finish) override;
633 void Destroy(bool have_context) override; 633 void Destroy(bool have_context) override;
634 634
635 protected: 635 protected:
636 ~TimeStampQuery() override; 636 ~TimeStampQuery() override;
637 637
638 private: 638 private:
639 std::unique_ptr<gfx::GPUTimer> gpu_timer_; 639 std::unique_ptr<gl::GPUTimer> gpu_timer_;
640 }; 640 };
641 641
642 TimeStampQuery::TimeStampQuery(QueryManager* manager, 642 TimeStampQuery::TimeStampQuery(QueryManager* manager,
643 GLenum target, 643 GLenum target,
644 int32_t shm_id, 644 int32_t shm_id,
645 uint32_t shm_offset) 645 uint32_t shm_offset)
646 : Query(manager, target, shm_id, shm_offset), 646 : Query(manager, target, shm_id, shm_offset),
647 gpu_timer_(manager->CreateGPUTimer(false)) {} 647 gpu_timer_(manager->CreateGPUTimer(false)) {}
648 648
649 bool TimeStampQuery::Begin() { 649 bool TimeStampQuery::Begin() {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 feature_info->feature_flags( 715 feature_info->feature_flags(
716 ).use_arb_occlusion_query_for_occlusion_query_boolean), 716 ).use_arb_occlusion_query_for_occlusion_query_boolean),
717 update_disjoints_continually_(false), 717 update_disjoints_continually_(false),
718 disjoint_notify_shm_id_(-1), 718 disjoint_notify_shm_id_(-1),
719 disjoint_notify_shm_offset_(0), 719 disjoint_notify_shm_offset_(0),
720 disjoints_notified_(0), 720 disjoints_notified_(0),
721 query_count_(0) { 721 query_count_(0) {
722 DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ && 722 DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ &&
723 use_arb_occlusion_query2_for_occlusion_query_boolean_)); 723 use_arb_occlusion_query2_for_occlusion_query_boolean_));
724 DCHECK(decoder); 724 DCHECK(decoder);
725 gfx::GLContext* context = decoder_->GetGLContext(); 725 gl::GLContext* context = decoder_->GetGLContext();
726 if (context) { 726 if (context) {
727 gpu_timing_client_ = context->CreateGPUTimingClient(); 727 gpu_timing_client_ = context->CreateGPUTimingClient();
728 } else { 728 } else {
729 gpu_timing_client_ = new gfx::GPUTimingClient(); 729 gpu_timing_client_ = new gl::GPUTimingClient();
730 } 730 }
731 } 731 }
732 732
733 QueryManager::~QueryManager() { 733 QueryManager::~QueryManager() {
734 DCHECK(queries_.empty()); 734 DCHECK(queries_.empty());
735 735
736 // If this triggers, that means something is keeping a reference to 736 // If this triggers, that means something is keeping a reference to
737 // a Query belonging to this. 737 // a Query belonging to this.
738 CHECK_EQ(query_count_, 0u); 738 CHECK_EQ(query_count_, 0u);
739 } 739 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 default: { 806 default: {
807 NOTREACHED(); 807 NOTREACHED();
808 } 808 }
809 } 809 }
810 std::pair<QueryMap::iterator, bool> result = 810 std::pair<QueryMap::iterator, bool> result =
811 queries_.insert(std::make_pair(client_id, query)); 811 queries_.insert(std::make_pair(client_id, query));
812 DCHECK(result.second); 812 DCHECK(result.second);
813 return query.get(); 813 return query.get();
814 } 814 }
815 815
816 std::unique_ptr<gfx::GPUTimer> QueryManager::CreateGPUTimer(bool elapsed_time) { 816 std::unique_ptr<gl::GPUTimer> QueryManager::CreateGPUTimer(bool elapsed_time) {
817 return gpu_timing_client_->CreateGPUTimer(elapsed_time); 817 return gpu_timing_client_->CreateGPUTimer(elapsed_time);
818 } 818 }
819 819
820 bool QueryManager::GPUTimingAvailable() { 820 bool QueryManager::GPUTimingAvailable() {
821 return gpu_timing_client_->IsAvailable(); 821 return gpu_timing_client_->IsAvailable();
822 } 822 }
823 823
824 void QueryManager::GenQueries(GLsizei n, const GLuint* queries) { 824 void QueryManager::GenQueries(GLsizei n, const GLuint* queries) {
825 DCHECK_GE(n, 0); 825 DCHECK_GE(n, 0);
826 for (GLsizei i = 0; i < n; ++i) { 826 for (GLsizei i = 0; i < n; ++i) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 for (std::pair<const GLenum, scoped_refptr<Query> >& it : active_queries_) { 1132 for (std::pair<const GLenum, scoped_refptr<Query> >& it : active_queries_) {
1133 if (it.second->IsPaused()) { 1133 if (it.second->IsPaused()) {
1134 it.second->Resume(); 1134 it.second->Resume();
1135 DCHECK(it.second->IsActive()); 1135 DCHECK(it.second->IsActive());
1136 } 1136 }
1137 } 1137 }
1138 } 1138 }
1139 1139
1140 } // namespace gles2 1140 } // namespace gles2
1141 } // namespace gpu 1141 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.h ('k') | gpu/command_buffer/service/query_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698