flutter_flutter/shell/gpu/gpu_surface_gl.h
Chinmay Garde 58e84c8bf0
Re-land "Support multiple shells in a single process. (#4932)" (#4998)
* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit 723c7d01439da4261bc836075fb55651ce9e7f03.
2018-04-13 13:48:15 -07:00

60 lines
1.4 KiB
C++

// Copyright 2016 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 SHELL_GPU_GPU_SURFACE_GL_H_
#define SHELL_GPU_GPU_SURFACE_GL_H_
#include "flutter/shell/common/surface.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/weak_ptr.h"
#include "third_party/skia/include/gpu/GrContext.h"
namespace shell {
class GPUSurfaceGLDelegate {
public:
virtual bool GLContextMakeCurrent() = 0;
virtual bool GLContextClearCurrent() = 0;
virtual bool GLContextPresent() = 0;
virtual intptr_t GLContextFBO() const = 0;
virtual bool UseOffscreenSurface() const { return false; }
};
class GPUSurfaceGL : public Surface {
public:
GPUSurfaceGL(GPUSurfaceGLDelegate* delegate);
~GPUSurfaceGL() override;
bool IsValid() override;
std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
GrContext* GetContext() override;
private:
GPUSurfaceGLDelegate* delegate_;
sk_sp<GrContext> context_;
sk_sp<SkSurface> onscreen_surface_;
sk_sp<SkSurface> offscreen_surface_;
bool valid_ = false;
fxl::WeakPtrFactory<GPUSurfaceGL> weak_factory_;
bool CreateOrUpdateSurfaces(const SkISize& size);
sk_sp<SkSurface> AcquireRenderSurface(const SkISize& size);
bool PresentSurface(SkCanvas* canvas);
FXL_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGL);
};
} // namespace shell
#endif // SHELL_GPU_GPU_SURFACE_GL_H_