2015-02-02 20:55:14 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HelloWorld_DEFINED
|
|
|
|
#define HelloWorld_DEFINED
|
|
|
|
|
|
|
|
#include "SkSurface.h"
|
|
|
|
#include "SkWindow.h"
|
|
|
|
|
|
|
|
class GrContext;
|
|
|
|
struct GrGLInterface;
|
|
|
|
class GrRenderTarget;
|
|
|
|
class SkCanvas;
|
|
|
|
|
|
|
|
class HelloWorldWindow : public SkOSWindow {
|
|
|
|
public:
|
|
|
|
enum DeviceType {
|
|
|
|
kRaster_DeviceType,
|
|
|
|
kGPU_DeviceType,
|
|
|
|
};
|
|
|
|
HelloWorldWindow(void* hwnd);
|
2015-03-26 01:17:31 +00:00
|
|
|
virtual ~HelloWorldWindow() override;
|
2015-02-02 20:55:14 +00:00
|
|
|
|
|
|
|
// Changes the device type of the object.
|
|
|
|
bool setUpBackend();
|
|
|
|
|
|
|
|
DeviceType getDeviceType() const { return fType; }
|
|
|
|
|
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
SkSurface* createSurface() override {
|
2015-06-23 13:26:08 +00:00
|
|
|
SkSurfaceProps props(INHERITED::getSurfaceProps());
|
2015-02-02 20:55:14 +00:00
|
|
|
if (kGPU_DeviceType == fType) {
|
2016-03-24 01:59:25 +00:00
|
|
|
return SkSurface::MakeRenderTargetDirect(fRenderTarget, &props).release();
|
2015-02-02 20:55:14 +00:00
|
|
|
}
|
|
|
|
static const SkImageInfo info = SkImageInfo::MakeN32Premul(
|
|
|
|
SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()));
|
2016-03-24 01:59:25 +00:00
|
|
|
return fSurface = SkSurface::MakeRaster(info, &props).release();
|
2015-06-23 13:26:08 +00:00
|
|
|
}
|
2015-02-02 20:55:14 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void draw(SkCanvas* canvas) override;
|
2015-02-02 20:55:14 +00:00
|
|
|
void drawContents(SkCanvas* canvas);
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onSizeChange() override;
|
2015-02-02 20:55:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool findNextMatch(); // Set example to the first one that matches FLAGS_match.
|
|
|
|
void setTitle();
|
|
|
|
void setUpRenderTarget();
|
2015-03-26 01:17:31 +00:00
|
|
|
bool onHandleChar(SkUnichar unichar) override;
|
2015-02-02 20:55:14 +00:00
|
|
|
void tearDownBackend();
|
|
|
|
|
|
|
|
// draw contents
|
|
|
|
SkScalar fRotationAngle;
|
|
|
|
|
|
|
|
// support framework
|
|
|
|
DeviceType fType;
|
|
|
|
SkSurface* fSurface;
|
|
|
|
GrContext* fContext;
|
|
|
|
GrRenderTarget* fRenderTarget;
|
|
|
|
AttachmentInfo fAttachmentInfo;
|
|
|
|
const GrGLInterface* fInterface;
|
|
|
|
|
|
|
|
typedef SkOSWindow INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|