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

Unified Diff: content/common/gpu/client/offscreen_context_command_buffer.cc

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Put OffscreenContext class in content/common/gpu/client for renderer Created 7 years, 10 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
Index: content/common/gpu/client/offscreen_context_command_buffer.cc
diff --git a/content/common/gpu/client/offscreen_context_command_buffer.cc b/content/common/gpu/client/offscreen_context_command_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..166b2d9db9d78ddd2afeef6f72137636eb1d3c19
--- /dev/null
+++ b/content/common/gpu/client/offscreen_context_command_buffer.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/gpu/client/offscreen_context_command_buffer.h"
+
+namespace content {
+
+OffscreenContextCommandBuffer::OffscreenContextCommandBuffer(
+ OffscreenContextCommandBufferClient* client)
+ : client_(client) {
+}
+
+OffscreenContextCommandBuffer::~OffscreenContextCommandBuffer() {
+ if (context3d_) {
+ context3d_->setContextLostCallback(NULL);
+ context3d_->setMemoryAllocationChangedCallbackCHROMIUM(NULL);
+ }
+}
+
+WebGraphicsContext3DCommandBufferImpl* OffscreenContextCommandBuffer::
+ Context3d() {
+ if (context3d_)
+ return context3d_.get();
+
+ context3d_.reset(client_->CreateOffscreenContext());
+ if (context3d_ &&
+ (!context3d_->makeContextCurrent() ||
+ context3d_->getGraphicsResetStatusARB()))
+ context3d_.reset();
+
+ client_->DidCreateContext(this, !!context3d_);
+ if (!context3d_)
+ return NULL;
+
+ context3d_->setContextLostCallback(this);
+ // TODO(danakj): Talk to the GPU mem manager directly.
+ context3d_->setMemoryAllocationChangedCallbackCHROMIUM(this);
+ return context3d_.get();
+}
+
+void OffscreenContextCommandBuffer::onContextLost() {
+ // Save the context3d until the notifications are done, but requests for a
+ // context should create a new one.
+ scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d =
+ context3d_.Pass();
+ if (context3d)
+ context3d->setMemoryAllocationChangedCallbackCHROMIUM(NULL);
+
+ // Inform the superclass.
+ DidLoseContext();
+
+ client_->DidLoseContext(this);
+}
+
+// WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation.
+void OffscreenContextCommandBuffer::onMemoryAllocationChanged(
+ WebKit::WebGraphicsMemoryAllocation allocation) {
+ SetGaneshContextMemoryLimit(!!allocation.gpuResourceSizeInBytes);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698