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

Unified Diff: o3d/gpu_plugin/gpu_processor_win.cc

Issue 234001: GPUProcessor uses O3D command buffer service to render to a window.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « o3d/gpu_plugin/gpu_processor_unittest.cc ('k') | o3d/gpu_plugin/system_services/shared_memory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: o3d/gpu_plugin/gpu_processor_win.cc
===================================================================
--- o3d/gpu_plugin/gpu_processor_win.cc (revision 26879)
+++ o3d/gpu_plugin/gpu_processor_win.cc (working copy)
@@ -9,31 +9,76 @@
namespace o3d {
namespace gpu_plugin {
-GPUProcessor::GPUProcessor(const NPObjectPointer<CommandBuffer>& command_buffer)
- : command_buffer_(command_buffer),
- window_handle_(NULL),
- window_width_(0),
- window_height_(0) {
+GPUProcessor::GPUProcessor(NPP npp,
+ const NPObjectPointer<CommandBuffer>& command_buffer)
+ : npp_(npp),
+ command_buffer_(command_buffer),
+ commands_per_update_(100) {
+ gapi_.reset(new command_buffer::GAPID3D9);
+
+ decoder_.reset(new command_buffer::GAPIDecoder(gapi_.get()));
+
+ NPObjectPointer<CHRSharedMemory> ring_buffer =
+ command_buffer->GetRingBuffer();
+
+ if (ring_buffer.Get()) {
+ parser_.reset(new command_buffer::CommandParser(ring_buffer->ptr,
+ ring_buffer->size,
+ 0,
+ ring_buffer->size,
+ 0,
+ decoder_.get()));
+ } else {
+ parser_.reset(new command_buffer::CommandParser(NULL, 0, 0, 0, 0,
+ decoder_.get()));
+ }
}
-void GPUProcessor::SetWindow(HWND handle, int width, int height) {
- window_handle_ = handle;
- window_width_ = width;
- window_height_ = height;
+GPUProcessor::GPUProcessor(NPP npp,
+ const NPObjectPointer<CommandBuffer>& command_buffer,
+ command_buffer::GAPID3D9* gapi,
+ command_buffer::GAPIDecoder* decoder,
+ command_buffer::CommandParser* parser,
+ int commands_per_update)
+ : npp_(npp),
+ command_buffer_(command_buffer),
+ commands_per_update_(commands_per_update) {
+ gapi_.reset(gapi);
+ decoder_.reset(decoder);
+ parser_.reset(parser);
}
-void GPUProcessor::DrawRectangle(uint32 color,
- int left, int top, int right, int bottom) {
- if (!window_handle_)
- return;
+bool GPUProcessor::Initialize(HWND handle) {
+ // Cannot reinitialize.
+ DCHECK(gapi_->hwnd() == NULL);
- HBRUSH brush = ::CreateSolidBrush(color);
- HDC dc = ::GetDC(window_handle_);
- RECT rect = { left, right, top, bottom };
- ::FillRect(dc, &rect, brush);
- ::ReleaseDC(window_handle_, dc);
- ::DeleteObject(brush);
+ // Initialize GAPI immediately if the window handle is valid.
+ if (handle) {
+ gapi_->set_hwnd(handle);
+ return gapi_->Initialize();
+ } else {
+ return true;
+ }
}
+void GPUProcessor::Destroy() {
+ // Destroy GAPI if window handle has not already become invalid.
+ if (gapi_->hwnd()) {
+ gapi_->Destroy();
+ gapi_->set_hwnd(NULL);
+ }
+}
+
+void GPUProcessor::SetWindow(HWND handle, int width, int height) {
+ if (handle == NULL) {
+ // Destroy GAPI when the window handle becomes invalid.
+ Destroy();
+ } else {
+ if (handle != gapi_->hwnd()) {
+ Initialize(handle);
+ }
+ }
+}
+
} // namespace gpu_plugin
} // namespace o3d
« no previous file with comments | « o3d/gpu_plugin/gpu_processor_unittest.cc ('k') | o3d/gpu_plugin/system_services/shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698