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
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkSurfaceProps.h"
|
|
|
|
#include "include/gpu/GrContext.h"
|
|
|
|
#include "include/gpu/GrTypes.h"
|
|
|
|
#include "tools/sk_app/DisplayParams.h"
|
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:
|
2017-05-02 20:15:53 +00:00
|
|
|
WindowContext(const DisplayParams& params)
|
2018-02-03 01:32:49 +00:00
|
|
|
: fContext(nullptr)
|
|
|
|
, fDisplayParams(params)
|
|
|
|
, fSampleCount(1)
|
|
|
|
, fStencilBits(0) {}
|
2016-05-20 13:01:06 +00:00
|
|
|
|
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;
|
|
|
|
|
2017-07-25 14:05:01 +00:00
|
|
|
GrContext* getGrContext() const { return fContext.get(); }
|
2016-05-20 13:01:06 +00:00
|
|
|
|
2017-02-24 20:22:53 +00:00
|
|
|
int width() const { return fWidth; }
|
|
|
|
int height() const { return fHeight; }
|
2017-02-24 23:04:47 +00:00
|
|
|
int sampleCount() const { return fSampleCount; }
|
|
|
|
int stencilBits() const { return fStencilBits; }
|
2017-02-24 20:22:53 +00:00
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
protected:
|
|
|
|
virtual bool isGpuContext() { return true; }
|
|
|
|
|
2017-07-25 14:05:01 +00:00
|
|
|
sk_sp<GrContext> fContext;
|
2016-05-20 13:01:06 +00:00
|
|
|
|
|
|
|
int fWidth;
|
|
|
|
int fHeight;
|
|
|
|
DisplayParams fDisplayParams;
|
2017-02-24 23:04:47 +00:00
|
|
|
|
|
|
|
// parameters obtained from the native window
|
|
|
|
// Note that the platform .cpp file is responsible for
|
|
|
|
// initializing fSampleCount and fStencilBits!
|
|
|
|
int fSampleCount;
|
|
|
|
int fStencilBits;
|
2016-05-05 19:32:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sk_app
|
|
|
|
|
|
|
|
#endif
|