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 UI_COMPOSITOR_OFFSCREEN_CONTEXT_H_ |
| 6 #define UI_COMPOSITOR_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 #include "ui/compositor/compositor_export.h" |
| 12 |
| 13 class GrContext; |
| 14 |
| 15 namespace ui { |
| 16 class ContextFactory; |
| 17 class OffscreenContext; |
| 18 |
| 19 class COMPOSITOR_EXPORT OffscreenContextClient { |
| 20 public: |
| 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 context and a GrContext that is |
| 27 // bounds to the offscreen context. |
| 28 class COMPOSITOR_EXPORT OffscreenContext |
| 29 : public NON_EXPORTED_BASE( |
| 30 WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback) { |
| 31 public: |
| 32 OffscreenContext( |
| 33 ui::ContextFactory* context_factory, |
| 34 OffscreenContextClient* client); |
| 35 virtual ~OffscreenContext(); |
| 36 |
| 37 WebKit::WebGraphicsContext3D* Context3d(); |
| 38 class GrContext* GrContext(); |
| 39 |
| 40 protected: |
| 41 // The limit of the number of textures we hold in the GrContext's |
| 42 // bitmap->texture cache. |
| 43 static const int kMaxGaneshTextureCacheCount = 2048; |
| 44 // The limit of the bytes allocated toward textures in the GrContext's |
| 45 // bitmap->texture cache. |
| 46 static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; |
| 47 |
| 48 WebKit::WebGraphicsContext3D* context3d_if_exists() const { |
| 49 return context3d_.get(); |
| 50 } |
| 51 class GrContext* gr_context_if_exists() const { return gr_context_.get(); } |
| 52 |
| 53 virtual void DidCreateContext(bool success); |
| 54 |
| 55 private: |
| 56 // WebGraphicsContextLostCallback implementation. |
| 57 virtual void onContextLost() OVERRIDE; |
| 58 |
| 59 ui::ContextFactory* context_factory_; |
| 60 OffscreenContextClient* client_; |
| 61 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; |
| 62 skia::RefPtr<class GrContext> gr_context_; |
| 63 }; |
| 64 |
| 65 } // namespace ui |
| 66 |
| 67 #endif // UI_COMPOSITOR_OFFSCREEN_CONTEXT_H_ |
OLD | NEW |