Index: cc/grcontext_provider.h |
diff --git a/cc/grcontext_provider.h b/cc/grcontext_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..19e4a20ab680c53eaf6d5682bbe2da7809e56643 |
--- /dev/null |
+++ b/cc/grcontext_provider.h |
@@ -0,0 +1,66 @@ |
+// Copyright 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 CC_GRCONTEXT_PROVIDER_H_ |
+#define CC_GRCONTEXT_PROVIDER_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "cc/cc_export.h" |
+#include "skia/ext/refptr.h" |
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" |
+ |
+class GrContext; |
+ |
+namespace cc { |
+class ResourceProvider; |
+ |
+class CC_EXPORT GrContextProvider |
+ : public WebKit::WebGraphicsContext3D:: |
+ WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { |
+ public: |
+ GrContextProvider(); |
+ virtual ~GrContextProvider(); |
+ |
+ void SetContext3d(WebKit::WebGraphicsContext3D* context3d); |
+ |
+ bool has_contexts() { return context3d_ && gr_context_; } |
+ |
+ class CC_EXPORT ScopedContexts { |
+ public: |
+ explicit ScopedContexts(GrContextProvider* grcontext_provider); |
+ ~ScopedContexts(); |
+ |
+ WebKit::WebGraphicsContext3D* context3d() { |
+ return grcontext_provider_->context3d_; |
+ } |
+ GrContext* gr_context() { |
+ return grcontext_provider_->gr_context_.get(); |
+ } |
+ |
+ protected: |
+ GrContextProvider* grcontext_provider_; |
+ }; |
+ |
+ class CC_EXPORT ScopedContextsFlushed : public ScopedContexts { |
+ public: |
+ ScopedContextsFlushed(ResourceProvider* resource_provider, |
+ GrContextProvider* grcontext_provider); |
+ ~ScopedContextsFlushed(); |
+ }; |
+ |
+ private: |
+ void SetGaneshContextMemoryLimit(bool nonzero_allocation); |
+ |
+ // TODO(danakj): Move this to content/ |
+ // WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation. |
+ virtual void onMemoryAllocationChanged( |
+ WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE; |
+ |
+ WebKit::WebGraphicsContext3D* context3d_; |
+ skia::RefPtr<GrContext> gr_context_; |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_GRCONTEXT_PROVIDER_H_ |