aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn20
-rw-r--r--example/HelloWorld.cpp17
-rw-r--r--example/HelloWorld.h4
3 files changed, 26 insertions, 15 deletions
diff --git a/BUILD.gn b/BUILD.gn
index ece39b05d9..29fc0204b3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1421,6 +1421,26 @@ if (skia_enable_tools) {
}
}
+ if (skia_enable_gpu && !skia_use_angle && (is_linux || is_win || is_mac)) {
+ test_app("HelloWorld") {
+ sources = [
+ "example/HelloWorld.cpp",
+ ]
+ if (is_mac) {
+ sources += [ "src/views/mac/skia_mac.mm" ]
+ } else if (is_win) {
+ sources += [ "src/views/win/skia_win.cpp" ]
+ } else if (is_linux) {
+ sources += [ "src/views/unix/skia_unix.cpp" ]
+ }
+ deps = [
+ ":gpu_tool_utils",
+ ":skia",
+ ":views",
+ ]
+ }
+ }
+
if (skia_enable_gpu) {
test_app("skpbench") {
sources = [
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index 2375e0016f..83bc4ecf44 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -39,14 +39,6 @@ HelloWorldWindow::~HelloWorldWindow() {
}
void HelloWorldWindow::tearDownBackend() {
- SkSafeUnref(fContext);
- fContext = NULL;
-
- SkSafeUnref(fInterface);
- fInterface = NULL;
-
- fGpuSurface = nullptr;
-
INHERITED::release();
}
@@ -67,10 +59,10 @@ bool HelloWorldWindow::setUpBackend() {
return false;
}
- fInterface = GrGLCreateNativeInterface();
+ fInterface.reset(GrGLCreateNativeInterface());
SkASSERT(NULL != fInterface);
- fContext = GrContext::MakeGL(fInterface).release();
+ fContext = GrContext::MakeGL(fInterface.get());
SkASSERT(NULL != fContext);
this->setUpGpuBackedSurface();
@@ -78,7 +70,7 @@ bool HelloWorldWindow::setUpBackend() {
}
void HelloWorldWindow::setUpGpuBackedSurface() {
- fGpuSurface = this->makeGpuBackedSurface(fAttachmentInfo, fInterface, fContext);
+ fGpuSurface = this->makeGpuBackedSurface(fAttachmentInfo, fInterface.get(), fContext.get());
}
void HelloWorldWindow::drawContents(SkCanvas* canvas) {
@@ -114,8 +106,7 @@ void HelloWorldWindow::drawContents(SkCanvas* canvas) {
// Draw a message with a nice black paint.
paint.setFlags(
SkPaint::kAntiAlias_Flag |
- SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotating.
- SkPaint::kUnderlineText_Flag);
+ SkPaint::kSubpixelText_Flag); // ... avoid waggly text when rotating.
paint.setColor(SK_ColorBLACK);
paint.setTextSize(20);
diff --git a/example/HelloWorld.h b/example/HelloWorld.h
index d3fc7cfb16..05d9b81e82 100644
--- a/example/HelloWorld.h
+++ b/example/HelloWorld.h
@@ -62,10 +62,10 @@ private:
// support framework
DeviceType fType;
sk_sp<SkSurface> fRasterSurface;
- GrContext* fContext;
+ sk_sp<GrContext> fContext;
sk_sp<SkSurface> fGpuSurface;
AttachmentInfo fAttachmentInfo;
- const GrGLInterface* fInterface;
+ sk_sp<const GrGLInterface> fInterface;
typedef SkOSWindow INHERITED;
};