skia2/tools/viewer/sk_app/WindowContext.h
Christopher Dalton 443ec1b794 Add onBackendCreated callback to Viewer
Also removes fWidth and fHeight from Window and instead
calls into WindowContent to get these values.

BUG=skia:

Change-Id: I72ee506004b7da73db9abb607a3bc82edfcf7d43
Reviewed-on: https://skia-review.googlesource.com/8795
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Yuqian Li <liyuqian@google.com>
2017-02-24 22:37:34 +00:00

65 lines
1.5 KiB
C++

/*
* 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
#include "DisplayParams.h"
#include "GrTypes.h"
#include "SkRefCnt.h"
#include "SkSurfaceProps.h"
class GrContext;
class SkSurface;
class GrRenderTarget;
namespace sk_app {
class WindowContext {
public:
WindowContext() : fContext(nullptr)
, fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) {}
virtual ~WindowContext() {}
virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
virtual void swapBuffers() = 0;
virtual bool isValid() = 0;
virtual void resize(int w, int h) = 0;
const DisplayParams& getDisplayParams() { return fDisplayParams; }
virtual void setDisplayParams(const DisplayParams& params) = 0;
SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; }
void setSurfaceProps(const SkSurfaceProps& props) {
fSurfaceProps = props;
}
virtual GrBackendContext getBackendContext() = 0;
GrContext* getGrContext() const { return fContext; }
int width() const { return fWidth; }
int height() const { return fHeight; }
protected:
virtual bool isGpuContext() { return true; }
GrContext* fContext;
int fWidth;
int fHeight;
DisplayParams fDisplayParams;
GrPixelConfig fPixelConfig;
SkSurfaceProps fSurfaceProps;
};
} // namespace sk_app
#endif