| Index: content/common/gpu/client/offscreen_context.h
|
| diff --git a/content/common/gpu/client/offscreen_context.h b/content/common/gpu/client/offscreen_context.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6c07a978b1fbf69cc72737eb4940d30cc28d0351
|
| --- /dev/null
|
| +++ b/content/common/gpu/client/offscreen_context.h
|
| @@ -0,0 +1,63 @@
|
| +// 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 CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_
|
| +#define CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "skia/ext/refptr.h"
|
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
|
| +
|
| +class GrContext;
|
| +
|
| +namespace content {
|
| +class OffscreenContext;
|
| +
|
| +class OffscreenContextClient {
|
| + public:
|
| + virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0;
|
| +
|
| + virtual void DidLoseContext(OffscreenContext* offscreen_context) = 0;
|
| + virtual void DidCreateContext(OffscreenContext* offscreen_context,
|
| + bool success) = 0;
|
| +};
|
| +
|
| +// This class lazily creates an offscreen GrContext that is bound to an
|
| +// offscreen context lazily created by its subclass implementation.
|
| +class OffscreenContext
|
| + : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback,
|
| + public WebKit::WebGraphicsContext3D::
|
| + WebGraphicsMemoryAllocationChangedCallbackCHROMIUM {
|
| + public:
|
| + explicit OffscreenContext(OffscreenContextClient* client);
|
| + virtual ~OffscreenContext();
|
| +
|
| + WebKit::WebGraphicsContext3D* Context3d();
|
| + class GrContext* GrContext();
|
| +
|
| + protected:
|
| + void SetGaneshContextMemoryLimit(bool nonzero_allocation);
|
| +
|
| + private:
|
| + // WebGraphicsContextLostCallback implementation.
|
| + virtual void onContextLost() OVERRIDE;
|
| + // WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation.
|
| + virtual void onMemoryAllocationChanged(
|
| + WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE;
|
| +
|
| + // 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;
|
| +
|
| + OffscreenContextClient* client_;
|
| + scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
|
| + skia::RefPtr<class GrContext> gr_context_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_COMMON_GPU_CLIENT_OFFSCREEN_CONTEXT_H_
|
|
|