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

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

Issue 465099: Removed command buffer's last dependency on NPAPI.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/message_loop.h"
5 #include "gpu/command_buffer/service/gpu_processor.h" 6 #include "gpu/command_buffer/service/gpu_processor.h"
6 #include "gpu/np_utils/np_browser.h"
7 7
8 using ::base::SharedMemory; 8 using ::base::SharedMemory;
9 using np_utils::NPBrowser;
10 9
11 namespace command_buffer { 10 namespace command_buffer {
12 11
13 GPUProcessor::~GPUProcessor() { 12 GPUProcessor::~GPUProcessor() {
14 } 13 }
15 14
16 namespace {
17 void InvokeProcessCommands(void* data) {
18 static_cast<GPUProcessor*>(data)->ProcessCommands();
19 }
20 } // namespace anonymous
21
22 void GPUProcessor::ProcessCommands() { 15 void GPUProcessor::ProcessCommands() {
23 if (command_buffer_->GetErrorStatus()) 16 if (command_buffer_->GetErrorStatus())
24 return; 17 return;
25 18
26 parser_->set_put(command_buffer_->GetPutOffset()); 19 parser_->set_put(command_buffer_->GetPutOffset());
27 20
28 int commands_processed = 0; 21 int commands_processed = 0;
29 while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) { 22 while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) {
30 command_buffer::parse_error::ParseError parse_error = 23 command_buffer::parse_error::ParseError parse_error =
31 parser_->ProcessCommand(); 24 parser_->ProcessCommand();
32 switch (parse_error) { 25 switch (parse_error) {
33 case command_buffer::parse_error::kParseUnknownCommand: 26 case command_buffer::parse_error::kParseUnknownCommand:
34 case command_buffer::parse_error::kParseInvalidArguments: 27 case command_buffer::parse_error::kParseInvalidArguments:
35 command_buffer_->SetParseError(parse_error); 28 command_buffer_->SetParseError(parse_error);
36 break; 29 break;
37 30
38 case command_buffer::parse_error::kParseInvalidSize: 31 case command_buffer::parse_error::kParseInvalidSize:
39 case command_buffer::parse_error::kParseOutOfBounds: 32 case command_buffer::parse_error::kParseOutOfBounds:
40 command_buffer_->SetParseError(parse_error); 33 command_buffer_->SetParseError(parse_error);
41 command_buffer_->RaiseErrorStatus(); 34 command_buffer_->RaiseErrorStatus();
42 return; 35 return;
43 } 36 }
44 37
45 ++commands_processed; 38 ++commands_processed;
46 } 39 }
47 40
48 command_buffer_->SetGetOffset(static_cast<int32>(parser_->get())); 41 command_buffer_->SetGetOffset(static_cast<int32>(parser_->get()));
49 42
50 if (!parser_->IsEmpty()) { 43 if (!parser_->IsEmpty()) {
51 NPBrowser::get()->PluginThreadAsyncCall(npp_, InvokeProcessCommands, this); 44 MessageLoop::current()->PostTask(
45 FROM_HERE, NewRunnableMethod(this, &GPUProcessor::ProcessCommands));
52 } 46 }
53 } 47 }
54 48
55 void *GPUProcessor::GetSharedMemoryAddress(int32 shm_id) { 49 void *GPUProcessor::GetSharedMemoryAddress(int32 shm_id) {
56 ::base::SharedMemory* shared_memory = 50 ::base::SharedMemory* shared_memory =
57 command_buffer_->GetTransferBuffer(shm_id); 51 command_buffer_->GetTransferBuffer(shm_id);
58 if (!shared_memory) 52 if (!shared_memory)
59 return NULL; 53 return NULL;
60 54
61 if (!shared_memory->memory()) { 55 if (!shared_memory->memory()) {
(...skipping 13 matching lines...) Expand all
75 return 0; 69 return 0;
76 70
77 return shared_memory->max_size(); 71 return shared_memory->max_size();
78 } 72 }
79 73
80 void GPUProcessor::set_token(int32 token) { 74 void GPUProcessor::set_token(int32 token) {
81 command_buffer_->SetToken(token); 75 command_buffer_->SetToken(token);
82 } 76 }
83 77
84 } // namespace command_buffer 78 } // namespace command_buffer
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_processor.h ('k') | gpu/command_buffer/service/gpu_processor_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698