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

Unified Diff: content/common/gpu/client/offscreen_context.h

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back to a single OffscreenContext class 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.h
diff --git a/content/common/gpu/client/offscreen_context.h b/content/common/gpu/client/offscreen_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..6c07a978b1fbf69cc72737eb4940d30cc28d0351
--- /dev/null
+++ b/content/common/gpu/client/offscreen_context.h
@@ -0,0 +1,63 @@
+// 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.
+
+#ifndef CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_
+#define CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "skia/ext/refptr.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+
+class GrContext;
+
+namespace content {
+class OffscreenContext;
+
+class OffscreenContextClient {
+ public:
+ virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0;
+
+ virtual void DidLoseContext(OffscreenContext* offscreen_context) = 0;
+ virtual void DidCreateContext(OffscreenContext* offscreen_context,
+ bool success) = 0;
+};
+
+// This class lazily creates an offscreen GrContext that is bound to an
+// offscreen context lazily created by its subclass implementation.
+class OffscreenContext
+ : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback,
+ public WebKit::WebGraphicsContext3D::
+ WebGraphicsMemoryAllocationChangedCallbackCHROMIUM {
+ public:
+ explicit OffscreenContext(OffscreenContextClient* client);
+ virtual ~OffscreenContext();
+
+ WebKit::WebGraphicsContext3D* Context3d();
piman 2013/02/11 18:45:33 nit: Context3D for consistency?
danakj 2013/02/11 18:58:13 Hm, I've been using Context3d for function names a
+ class GrContext* GrContext();
+
+ protected:
+ void SetGaneshContextMemoryLimit(bool nonzero_allocation);
+
+ private:
+ // WebGraphicsContextLostCallback implementation.
+ virtual void onContextLost() OVERRIDE;
+ // WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation.
+ virtual void onMemoryAllocationChanged(
+ WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE;
+
+ // The limit of the number of textures we hold in the GrContext's
+ // bitmap->texture cache.
+ static const int kMaxGaneshTextureCacheCount = 2048;
+ // The limit of the bytes allocated toward textures in the GrContext's
+ // bitmap->texture cache.
+ static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024;
+
+ OffscreenContextClient* client_;
+ scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
+ skia::RefPtr<class GrContext> gr_context_;
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_

Powered by Google App Engine
This is Rietveld 408576698