skia2/tools/viewer/sk_app/GLWindowContext.h
Brian Osman f750fbcb69 Simplify viewer's handling of backbuffer surface and color space
WindowContext still supports color spaces, but not other color
types. Any off-screen rendering is the app's responsibility.

This change also adds (working) F16 support to viewer. Note that
the previous 10-bit and FP16 support in WindowContext was broken.
There was no code to push the off-screen canvas to the window.
If you ever made it to the unreachable off-screen code path in
createSurface, it would have simply stopped drawing.

The decision to limit the window's gamut to sRGB is mostly driven
by my desire to add real-time editing of gamut. This design lets
us do that, without tearing down and rebuilding the window for
every change. An application could still supply a different gamut
via setDisplayParams and render directly to the back buffer with
proper color correction.

BUG=skia:

Change-Id: I94df35c7a42faee396009acc83683e40bb3c284d
Reviewed-on: https://skia-review.googlesource.com/8153
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-02-08 17:34:05 +00:00

66 lines
1.7 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 GLWindowContext_DEFINED
#define GLWindowContext_DEFINED
#include "gl/GrGLInterface.h"
#include "SkRefCnt.h"
#include "SkSurface.h"
#include "WindowContext.h"
class GrContext;
namespace sk_app {
class GLWindowContext : public WindowContext {
public:
sk_sp<SkSurface> getBackbufferSurface() override;
bool isValid() override { return SkToBool(fBackendContext.get()); }
void resize(int w, int h) override;
void swapBuffers() override;
void setDisplayParams(const DisplayParams& params) override;
GrBackendContext getBackendContext() override {
return (GrBackendContext) fBackendContext.get();
}
protected:
GLWindowContext(const DisplayParams&);
// This should be called by subclass constructor. It is also called when window/display
// parameters change. This will in turn call onInitializeContext().
void initializeContext();
virtual void onInitializeContext() = 0;
// This should be called by subclass destructor. It is also called when window/display
// parameters change prior to initializing a new GL context. This will in turn call
// onDestroyContext().
void destroyContext();
virtual void onDestroyContext() = 0;
virtual void onSwapBuffers() = 0;
sk_sp<const GrGLInterface> fBackendContext;
sk_sp<SkSurface> fSurface;
// parameters obtained from the native window
// Note that the platform .cpp file is responsible for
// initializing fSampleCount and fStencilBits!
int fSampleCount;
int fStencilBits;
};
} // namespace sk_app
#endif