| Index: ui/compositor/offscreen_context.h
|
| diff --git a/ui/compositor/offscreen_context.h b/ui/compositor/offscreen_context.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2a83d0ec28364016b1760939c1028b6cfd1eea69
|
| --- /dev/null
|
| +++ b/ui/compositor/offscreen_context.h
|
| @@ -0,0 +1,67 @@
|
| +// 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 UI_COMPOSITOR_OFFSCREEN_CONTEXT_H_
|
| +#define UI_COMPOSITOR_OFFSCREEN_CONTEXT_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "skia/ext/refptr.h"
|
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
|
| +#include "ui/compositor/compositor_export.h"
|
| +
|
| +class GrContext;
|
| +
|
| +namespace ui {
|
| +class ContextFactory;
|
| +class OffscreenContext;
|
| +
|
| +class COMPOSITOR_EXPORT OffscreenContextClient {
|
| + public:
|
| + virtual void DidLoseContext(OffscreenContext* offscreen_context) = 0;
|
| + virtual void DidCreateContext(OffscreenContext* offscreen_context,
|
| + bool success) = 0;
|
| +};
|
| +
|
| +// This class lazily creates an offscreen context and a GrContext that is
|
| +// bounds to the offscreen context.
|
| +class COMPOSITOR_EXPORT OffscreenContext
|
| + : public NON_EXPORTED_BASE(
|
| + WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback) {
|
| + public:
|
| + OffscreenContext(
|
| + ui::ContextFactory* context_factory,
|
| + OffscreenContextClient* client);
|
| + virtual ~OffscreenContext();
|
| +
|
| + WebKit::WebGraphicsContext3D* Context3d();
|
| + class GrContext* GrContext();
|
| +
|
| + protected:
|
| + // 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;
|
| +
|
| + WebKit::WebGraphicsContext3D* context3d_if_exists() const {
|
| + return context3d_.get();
|
| + }
|
| + class GrContext* gr_context_if_exists() const { return gr_context_.get(); }
|
| +
|
| + virtual void DidCreateContext(bool success);
|
| +
|
| + private:
|
| + // WebGraphicsContextLostCallback implementation.
|
| + virtual void onContextLost() OVERRIDE;
|
| +
|
| + ui::ContextFactory* context_factory_;
|
| + OffscreenContextClient* client_;
|
| + scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
|
| + skia::RefPtr<class GrContext> gr_context_;
|
| +};
|
| +
|
| +} // namespace ui
|
| +
|
| +#endif // UI_COMPOSITOR_OFFSCREEN_CONTEXT_H_
|
|
|