| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 * | 6 * |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "VisualBench.h" | 9 #include "VisualBench.h" |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 void VisualBench::resetContext() { | 102 void VisualBench::resetContext() { |
| 103 this->tearDownContext(); | 103 this->tearDownContext(); |
| 104 this->setupContext(); | 104 this->setupContext(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void VisualBench::setupContext() { | 107 void VisualBench::setupContext() { |
| 108 int screenSamples = FLAGS_offscreen ? 0 : FLAGS_msaa; | 108 int screenSamples = FLAGS_offscreen ? 0 : FLAGS_msaa; |
| 109 if (!this->attach(kNativeGL_BackEndType, screenSamples, &fAttachmentInfo)) { | 109 if (!this->attach(kNativeGL_BackEndType, screenSamples, &fAttachmentInfo)) { |
| 110 SkDebugf("Not possible to create backend.\n"); | 110 SkDebugf("Not possible to create backend.\n"); |
| 111 INHERITED::detach(); | 111 INHERITED::release(); |
| 112 SkFAIL("Could not create backend\n"); | 112 SkFAIL("Could not create backend\n"); |
| 113 } | 113 } |
| 114 | 114 |
| 115 this->setVsync(false); | 115 this->setVsync(false); |
| 116 | 116 |
| 117 fSurface.reset(nullptr); | 117 fSurface.reset(nullptr); |
| 118 | 118 |
| 119 fInterface.reset(GrGLCreateNativeInterface()); | 119 fInterface.reset(GrGLCreateNativeInterface()); |
| 120 | 120 |
| 121 // TODO use the GLContext creation factories and also set this all up in con
figs | 121 // TODO use the GLContext creation factories and also set this all up in con
figs |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 this->setupRenderTarget(); | 132 this->setupRenderTarget(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void VisualBench::tearDownContext() { | 135 void VisualBench::tearDownContext() { |
| 136 if (fContext) { | 136 if (fContext) { |
| 137 // We abandon the context in case SkWindow has kept a ref to the surface | 137 // We abandon the context in case SkWindow has kept a ref to the surface |
| 138 fContext->abandonContext(); | 138 fContext->abandonContext(); |
| 139 fContext.reset(); | 139 fContext.reset(); |
| 140 fSurface.reset(); | 140 fSurface.reset(); |
| 141 fInterface.reset(); | 141 fInterface.reset(); |
| 142 this->detach(); | 142 this->release(); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 void VisualBench::setupRenderTarget() { | 146 void VisualBench::setupRenderTarget() { |
| 147 if (fContext) { | 147 if (fContext) { |
| 148 fRenderTarget.reset(this->renderTarget(fAttachmentInfo, fInterface, fCon
text)); | 148 fRenderTarget.reset(this->renderTarget(fAttachmentInfo, fInterface, fCon
text)); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 void VisualBench::draw(SkCanvas* canvas) { | 152 void VisualBench::draw(SkCanvas* canvas) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 | 187 |
| 188 void application_term() { | 188 void application_term() { |
| 189 SkEvent::Term(); | 189 SkEvent::Term(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { | 192 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { |
| 193 return new VisualBench(hwnd, argc, argv); | 193 return new VisualBench(hwnd, argc, argv); |
| 194 } | 194 } |
| 195 | 195 |
| OLD | NEW |