2016-05-05 19:32:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#ifndef WindowContext_DEFINED
|
|
|
|
#define WindowContext_DEFINED
|
|
|
|
|
2016-05-06 20:28:57 +00:00
|
|
|
#include "DisplayParams.h"
|
2016-05-05 19:32:03 +00:00
|
|
|
#include "GrTypes.h"
|
2016-05-20 13:01:06 +00:00
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkSurfaceProps.h"
|
2016-05-05 19:32:03 +00:00
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
class GrContext;
|
2016-05-05 19:32:03 +00:00
|
|
|
class SkSurface;
|
2016-05-20 13:01:06 +00:00
|
|
|
class GrRenderTarget;
|
2016-05-05 19:32:03 +00:00
|
|
|
|
|
|
|
namespace sk_app {
|
|
|
|
|
|
|
|
class WindowContext {
|
|
|
|
public:
|
2016-05-20 13:01:06 +00:00
|
|
|
WindowContext() : fContext(nullptr)
|
|
|
|
, fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) {}
|
|
|
|
|
2016-05-05 19:32:03 +00:00
|
|
|
virtual ~WindowContext() {}
|
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
|
2016-05-05 19:32:03 +00:00
|
|
|
|
|
|
|
virtual void swapBuffers() = 0;
|
|
|
|
|
|
|
|
virtual bool isValid() = 0;
|
|
|
|
|
2016-07-27 15:50:12 +00:00
|
|
|
virtual void resize(int w, int h) = 0;
|
2016-05-05 19:32:03 +00:00
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
const DisplayParams& getDisplayParams() { return fDisplayParams; }
|
2016-05-06 20:28:57 +00:00
|
|
|
virtual void setDisplayParams(const DisplayParams& params) = 0;
|
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; }
|
|
|
|
void setSurfaceProps(const SkSurfaceProps& props) {
|
|
|
|
fSurfaceProps = props;
|
|
|
|
}
|
|
|
|
|
2016-05-05 19:32:03 +00:00
|
|
|
virtual GrBackendContext getBackendContext() = 0;
|
2016-06-09 20:07:13 +00:00
|
|
|
GrContext* getGrContext() const { return fContext; }
|
2016-05-20 13:01:06 +00:00
|
|
|
|
2016-06-16 21:10:34 +00:00
|
|
|
sk_sp<SkSurface> createOffscreenSurface(bool sRGB);
|
2016-05-20 13:01:06 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool isGpuContext() { return true; }
|
|
|
|
|
2016-07-19 16:46:29 +00:00
|
|
|
sk_sp<SkSurface> createRenderSurface(GrBackendRenderTargetDesc, int colorBits);
|
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
GrContext* fContext;
|
|
|
|
|
|
|
|
int fWidth;
|
|
|
|
int fHeight;
|
|
|
|
DisplayParams fDisplayParams;
|
|
|
|
GrPixelConfig fPixelConfig;
|
|
|
|
SkSurfaceProps fSurfaceProps;
|
2016-06-16 21:10:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
sk_sp<SkSurface> createSurface(
|
2016-07-19 16:46:29 +00:00
|
|
|
GrBackendRenderTargetDesc*, int colorBits, bool offscreen, bool forceSRGB);
|
2016-05-05 19:32:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sk_app
|
|
|
|
|
|
|
|
#endif
|