OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "skia/ext/refptr.h" |
| 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 11 |
| 12 class GrContext; |
| 13 |
| 14 namespace content { |
| 15 class OffscreenContext; |
| 16 |
| 17 class OffscreenContextClient { |
| 18 public: |
| 19 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; |
| 20 |
| 21 virtual void DidLoseContext(OffscreenContext* offscreen_context) = 0; |
| 22 virtual void DidCreateContext(OffscreenContext* offscreen_context, |
| 23 bool success) = 0; |
| 24 }; |
| 25 |
| 26 // This class lazily creates an offscreen GrContext that is bound to an |
| 27 // offscreen context lazily created by its subclass implementation. |
| 28 class OffscreenContext |
| 29 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback, |
| 30 public WebKit::WebGraphicsContext3D:: |
| 31 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { |
| 32 public: |
| 33 explicit OffscreenContext(OffscreenContextClient* client); |
| 34 virtual ~OffscreenContext(); |
| 35 |
| 36 WebKit::WebGraphicsContext3D* Context3d(); |
| 37 class GrContext* GrContext(); |
| 38 |
| 39 protected: |
| 40 void SetGaneshContextMemoryLimit(bool nonzero_allocation); |
| 41 |
| 42 private: |
| 43 // WebGraphicsContextLostCallback implementation. |
| 44 virtual void onContextLost() OVERRIDE; |
| 45 // WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation. |
| 46 virtual void onMemoryAllocationChanged( |
| 47 WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE; |
| 48 |
| 49 // The limit of the number of textures we hold in the GrContext's |
| 50 // bitmap->texture cache. |
| 51 static const int kMaxGaneshTextureCacheCount = 2048; |
| 52 // The limit of the bytes allocated toward textures in the GrContext's |
| 53 // bitmap->texture cache. |
| 54 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; |
| 55 |
| 56 OffscreenContextClient* client_; |
| 57 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; |
| 58 skia::RefPtr<class GrContext> gr_context_; |
| 59 }; |
| 60 |
| 61 } // namespace content |
| 62 |
| 63 #endif // CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_ |
OLD | NEW |