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

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

Issue 555020: Redesigned CommandBuffer and NPDevice3D interfaces (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_buffer_service_unittest.cc ('k') | gpu/command_buffer/service/gpu_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698