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

Unified Diff: chrome/renderer/webplugin_delegate_pepper.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/webplugin_delegate_pepper.h ('k') | gpu/command_buffer/client/cmd_buffer_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/webplugin_delegate_pepper.cc
===================================================================
--- chrome/renderer/webplugin_delegate_pepper.cc (revision 37414)
+++ chrome/renderer/webplugin_delegate_pepper.cc (working copy)
@@ -352,13 +352,15 @@
if (command_buffer_.get()) {
// Initialize the proxy command buffer.
if (command_buffer_->Initialize(config->commandBufferEntries)) {
+ // Get the initial command buffer state.
+ gpu::CommandBuffer::State state = command_buffer_->GetState();
+
// Initialize the 3D context.
context->reserved = NULL;
Buffer ring_buffer = command_buffer_->GetRingBuffer();
context->commandBuffer = ring_buffer.ptr;
- context->commandBufferEntries = command_buffer_->GetSize();
- context->getOffset = command_buffer_->GetGetOffset();
- context->putOffset = command_buffer_->GetPutOffset();
+ context->commandBufferEntries = state.size;
+ Synchronize3DContext(context, state);
// Ensure the service knows the window size before rendering anything.
nested_delegate_->UpdateGeometry(window_rect_, clip_rect_);
@@ -392,32 +394,7 @@
NPDeviceContext3D* context,
int32 state,
int32* value) {
-#if defined(ENABLE_GPU)
- if (!command_buffer_.get())
- return NPERR_GENERIC_ERROR;
-
- switch (state) {
- case NPDeviceContext3DState_GetOffset:
- context->getOffset = *value = command_buffer_->GetGetOffset();
- break;
- case NPDeviceContext3DState_PutOffset:
- *value = command_buffer_->GetPutOffset();
- break;
- case NPDeviceContext3DState_Token:
- *value = command_buffer_->GetToken();
- break;
- case NPDeviceContext3DState_ParseError:
- *value = command_buffer_->ResetParseError();
- break;
- case NPDeviceContext3DState_ErrorStatus:
- *value = command_buffer_->GetErrorStatus() ? 1 : 0;
- break;
- default:
- return NPERR_GENERIC_ERROR;
- };
-#endif // ENABLE_GPU
-
- return NPERR_NO_ERROR;
+ return NPERR_GENERIC_ERROR;
}
NPError WebPluginDelegatePepper::Device3DFlushContext(
@@ -426,8 +403,16 @@
NPDeviceFlushContextCallbackPtr callback,
void* user_data) {
#if defined(ENABLE_GPU)
- DCHECK(callback == NULL);
- context->getOffset = command_buffer_->SyncOffsets(context->putOffset);
+ gpu::CommandBuffer::State state;
+ // Only flush if new commands have been put in the command buffer. Otherwise
+ // update the state to the current service state.
+ if (context->putOffset == last_command_buffer_put_offset_) {
+ state = command_buffer_->GetState();
+ } else {
+ last_command_buffer_put_offset_ = context->putOffset;
+ state = command_buffer_->Flush(context->putOffset);
+ }
+ Synchronize3DContext(context, state);
#endif // ENABLE_GPU
return NPERR_NO_ERROR;
}
@@ -556,7 +541,8 @@
: render_view_(render_view),
plugin_(NULL),
instance_(instance),
- nested_delegate_(NULL) {
+ nested_delegate_(NULL),
+ last_command_buffer_put_offset_(-1) {
// For now we keep a window struct, although it isn't used.
memset(&window_, 0, sizeof(window_));
// All Pepper plugins are windowless and transparent.
@@ -720,3 +706,14 @@
}
return instance()->NPP_HandleEvent(&npevent) != 0;
}
+
+#if defined(ENABLE_GPU)
+void WebPluginDelegatePepper::Synchronize3DContext(
+ NPDeviceContext3D* context,
+ gpu::CommandBuffer::State state) {
+ context->getOffset = state.get_offset;
+ context->putOffset = state.put_offset;
+ context->token = state.token;
+ context->error = static_cast<int32>(state.error);
+}
+#endif // ENABLE_GPU
« no previous file with comments | « chrome/renderer/webplugin_delegate_pepper.h ('k') | gpu/command_buffer/client/cmd_buffer_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698