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

Side by Side Diff: content/common/gpu/gpu_channel.cc

Issue 564903002: Merge GpuCommandBufferMsg_SetLatencyInfo into GpuCommandBufferMsg_AsyncFlush (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove ShallowFlushCHROMIUM() in CompositorOutputSurface::SwapBuffers Created 6 years, 3 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
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 IPC_END_MESSAGE_MAP() 660 IPC_END_MESSAGE_MAP()
661 DCHECK(handled) << msg.type(); 661 DCHECK(handled) << msg.type();
662 return handled; 662 return handled;
663 } 663 }
664 664
665 size_t GpuChannel::MatchSwapBufferMessagesPattern( 665 size_t GpuChannel::MatchSwapBufferMessagesPattern(
666 IPC::Message* current_message) { 666 IPC::Message* current_message) {
667 DCHECK(current_message); 667 DCHECK(current_message);
668 if (deferred_messages_.empty() || !current_message) 668 if (deferred_messages_.empty() || !current_message)
669 return 0; 669 return 0;
670 // Only care about SetLatencyInfo and AsyncFlush message. 670 // Only care about AsyncFlush message.
671 if (current_message->type() != GpuCommandBufferMsg_SetLatencyInfo::ID && 671 if (current_message->type() != GpuCommandBufferMsg_AsyncFlush::ID)
672 current_message->type() != GpuCommandBufferMsg_AsyncFlush::ID)
673 return 0; 672 return 0;
674 673
675 size_t index = 0; 674 size_t index = 0;
676 int32 routing_id = current_message->routing_id(); 675 int32 routing_id = current_message->routing_id();
677 676
678 // In case of the current message is SetLatencyInfo, we try to look ahead one
679 // more deferred messages.
680 IPC::Message *first_message = NULL;
681 IPC::Message *second_message = NULL;
682
683 // Fetch the first message and move index to point to the second message. 677 // Fetch the first message and move index to point to the second message.
684 first_message = deferred_messages_[index++]; 678 IPC::Message* first_message = deferred_messages_[index++];
685 679
686 // If the current message is AsyncFlush, the expected message sequence for 680 // If the current message is AsyncFlush, the expected message sequence for
687 // SwapBuffer should be AsyncFlush->Echo. We only try to match Echo message. 681 // SwapBuffer should be AsyncFlush->Echo. We only try to match Echo message.
688 if (current_message->type() == GpuCommandBufferMsg_AsyncFlush::ID && 682 if (current_message->type() == GpuCommandBufferMsg_AsyncFlush::ID &&
689 first_message->type() == GpuCommandBufferMsg_Echo::ID && 683 first_message->type() == GpuCommandBufferMsg_Echo::ID &&
690 first_message->routing_id() == routing_id) { 684 first_message->routing_id() == routing_id) {
691 return 1; 685 return 1;
692 } 686 }
693 687
694 // If the current message is SetLatencyInfo, the expected message sequence
695 // for SwapBuffer should be SetLatencyInfo->AsyncFlush->Echo (optional).
696 if (current_message->type() == GpuCommandBufferMsg_SetLatencyInfo::ID &&
697 first_message->type() == GpuCommandBufferMsg_AsyncFlush::ID &&
698 first_message->routing_id() == routing_id) {
699 if (deferred_messages_.size() >= 2)
700 second_message = deferred_messages_[index];
701 if (!second_message)
702 return 1;
703 if (second_message->type() == GpuCommandBufferMsg_Echo::ID &&
704 second_message->routing_id() == routing_id) {
705 return 2;
706 }
707 }
708 // No matched message is found. 688 // No matched message is found.
709 return 0; 689 return 0;
710 } 690 }
711 691
712 void GpuChannel::HandleMessage() { 692 void GpuChannel::HandleMessage() {
713 handle_messages_scheduled_ = false; 693 handle_messages_scheduled_ = false;
714 if (deferred_messages_.empty()) 694 if (deferred_messages_.empty())
715 return; 695 return;
716 696
717 size_t matched_messages_num = 0; 697 size_t matched_messages_num = 0;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 744 }
765 if (message_processed) 745 if (message_processed)
766 MessageProcessed(); 746 MessageProcessed();
767 747
768 if (deferred_messages_.empty()) 748 if (deferred_messages_.empty())
769 break; 749 break;
770 750
771 // We process the pending messages immediately if these messages matches 751 // We process the pending messages immediately if these messages matches
772 // the pattern of SwapBuffers, for example, GLRenderer always issues 752 // the pattern of SwapBuffers, for example, GLRenderer always issues
773 // SwapBuffers calls with a specific IPC message patterns, for example, 753 // SwapBuffers calls with a specific IPC message patterns, for example,
774 // it should be SetLatencyInfo->AsyncFlush->Echo sequence. 754 // it should be AsyncFlush->Echo sequence.
775 // 755 //
776 // Instead of posting a task to message loop, it could avoid the possibility 756 // Instead of posting a task to message loop, it could avoid the possibility
777 // of being blocked by other channels, and make SwapBuffers executed as soon 757 // of being blocked by other channels, and make SwapBuffers executed as soon
778 // as possible. 758 // as possible.
779 if (!should_handle_swapbuffer_msgs_immediate) { 759 if (!should_handle_swapbuffer_msgs_immediate) {
780 // Start from the current processing message to match SwapBuffer pattern. 760 // Start from the current processing message to match SwapBuffer pattern.
781 matched_messages_num = MatchSwapBufferMessagesPattern(message.get()); 761 matched_messages_num = MatchSwapBufferMessagesPattern(message.get());
782 should_handle_swapbuffer_msgs_immediate = 762 should_handle_swapbuffer_msgs_immediate =
783 matched_messages_num > 0 && stub; 763 matched_messages_num > 0 && stub;
784 } else { 764 } else {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 uint64 GpuChannel::GetMemoryUsage() { 866 uint64 GpuChannel::GetMemoryUsage() {
887 uint64 size = 0; 867 uint64 size = 0;
888 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 868 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
889 !it.IsAtEnd(); it.Advance()) { 869 !it.IsAtEnd(); it.Advance()) {
890 size += it.GetCurrentValue()->GetMemoryUsage(); 870 size += it.GetCurrentValue()->GetMemoryUsage();
891 } 871 }
892 return size; 872 return size;
893 } 873 }
894 874
895 } // namespace content 875 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698