OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_GRCONTEXT_PROVIDER_H_ |
| 6 #define CC_GRCONTEXT_PROVIDER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/cc_export.h" |
| 10 #include "skia/ext/refptr.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 12 |
| 13 class GrContext; |
| 14 |
| 15 namespace cc { |
| 16 class ResourceProvider; |
| 17 |
| 18 class CC_EXPORT GrContextProvider |
| 19 : public WebKit::WebGraphicsContext3D:: |
| 20 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { |
| 21 public: |
| 22 GrContextProvider(); |
| 23 virtual ~GrContextProvider(); |
| 24 |
| 25 void SetContext3d(WebKit::WebGraphicsContext3D* context3d); |
| 26 |
| 27 bool has_contexts() { return context3d_ && gr_context_; } |
| 28 |
| 29 class CC_EXPORT ScopedContexts { |
| 30 public: |
| 31 explicit ScopedContexts(GrContextProvider* grcontext_provider); |
| 32 ~ScopedContexts(); |
| 33 |
| 34 WebKit::WebGraphicsContext3D* context3d() { |
| 35 return grcontext_provider_->context3d_; |
| 36 } |
| 37 GrContext* gr_context() { |
| 38 return grcontext_provider_->gr_context_.get(); |
| 39 } |
| 40 |
| 41 protected: |
| 42 GrContextProvider* grcontext_provider_; |
| 43 }; |
| 44 |
| 45 class CC_EXPORT ScopedContextsFlushed : public ScopedContexts { |
| 46 public: |
| 47 ScopedContextsFlushed(ResourceProvider* resource_provider, |
| 48 GrContextProvider* grcontext_provider); |
| 49 ~ScopedContextsFlushed(); |
| 50 }; |
| 51 |
| 52 private: |
| 53 void SetGaneshContextMemoryLimit(bool nonzero_allocation); |
| 54 |
| 55 // TODO(danakj): Move this to content/ |
| 56 // WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation. |
| 57 virtual void onMemoryAllocationChanged( |
| 58 WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE; |
| 59 |
| 60 WebKit::WebGraphicsContext3D* context3d_; |
| 61 skia::RefPtr<GrContext> gr_context_; |
| 62 }; |
| 63 |
| 64 } // namespace cc |
| 65 |
| 66 #endif // CC_GRCONTEXT_PROVIDER_H_ |
OLD | NEW |