OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/message_loop.h" |
6 #include "gpu/command_buffer/service/gpu_processor.h" | 6 #include "gpu/command_buffer/service/gpu_processor.h" |
7 | 7 |
8 using ::base::SharedMemory; | 8 using ::base::SharedMemory; |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
(...skipping 14 matching lines...) Expand all Loading... |
25 commands_per_update_(commands_per_update) { | 25 commands_per_update_(commands_per_update) { |
26 DCHECK(command_buffer); | 26 DCHECK(command_buffer); |
27 decoder_.reset(decoder); | 27 decoder_.reset(decoder); |
28 parser_.reset(parser); | 28 parser_.reset(parser); |
29 } | 29 } |
30 | 30 |
31 GPUProcessor::~GPUProcessor() { | 31 GPUProcessor::~GPUProcessor() { |
32 } | 32 } |
33 | 33 |
34 void GPUProcessor::ProcessCommands() { | 34 void GPUProcessor::ProcessCommands() { |
35 if (command_buffer_->GetErrorStatus()) | 35 CommandBuffer::State state = command_buffer_->GetState(); |
| 36 if (state.error != parse_error::kParseNoError) |
36 return; | 37 return; |
37 | 38 |
38 if (decoder_.get()) { | 39 if (decoder_.get()) { |
39 // TODO(apatrick): need to do more than this on failure. | 40 // TODO(apatrick): need to do more than this on failure. |
40 if (!decoder_->MakeCurrent()) | 41 if (!decoder_->MakeCurrent()) |
41 return; | 42 return; |
42 } | 43 } |
43 | 44 |
44 parser_->set_put(command_buffer_->GetPutOffset()); | 45 parser_->set_put(state.put_offset); |
45 | 46 |
46 int commands_processed = 0; | 47 int commands_processed = 0; |
47 while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) { | 48 while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) { |
48 parse_error::ParseError parse_error = parser_->ProcessCommand(); | 49 parse_error::ParseError parse_error = parser_->ProcessCommand(); |
49 switch (parse_error) { | 50 if (parse_error != parse_error::kParseNoError) { |
50 case parse_error::kParseUnknownCommand: | 51 command_buffer_->SetParseError(parse_error); |
51 case parse_error::kParseInvalidArguments: | 52 return; |
52 command_buffer_->SetParseError(parse_error); | |
53 break; | |
54 | |
55 case parse_error::kParseInvalidSize: | |
56 case parse_error::kParseOutOfBounds: | |
57 command_buffer_->SetParseError(parse_error); | |
58 command_buffer_->RaiseErrorStatus(); | |
59 return; | |
60 case gpu::parse_error::kParseNoError: | |
61 break; | |
62 } | 53 } |
63 | |
64 ++commands_processed; | 54 ++commands_processed; |
65 } | 55 } |
66 | 56 |
67 command_buffer_->SetGetOffset(static_cast<int32>(parser_->get())); | 57 command_buffer_->SetGetOffset(static_cast<int32>(parser_->get())); |
68 | 58 |
69 if (!parser_->IsEmpty()) { | 59 if (!parser_->IsEmpty()) { |
70 MessageLoop::current()->PostTask( | 60 MessageLoop::current()->PostTask( |
71 FROM_HERE, NewRunnableMethod(this, &GPUProcessor::ProcessCommands)); | 61 FROM_HERE, NewRunnableMethod(this, &GPUProcessor::ProcessCommands)); |
72 } | 62 } |
73 } | 63 } |
74 | 64 |
75 Buffer GPUProcessor::GetSharedMemoryBuffer(int32 shm_id) { | 65 Buffer GPUProcessor::GetSharedMemoryBuffer(int32 shm_id) { |
76 return command_buffer_->GetTransferBuffer(shm_id); | 66 return command_buffer_->GetTransferBuffer(shm_id); |
77 } | 67 } |
78 | 68 |
79 void GPUProcessor::set_token(int32 token) { | 69 void GPUProcessor::set_token(int32 token) { |
80 command_buffer_->SetToken(token); | 70 command_buffer_->SetToken(token); |
81 } | 71 } |
82 | 72 |
83 } // namespace gpu | 73 } // namespace gpu |
OLD | NEW |