OLD | NEW |
(Empty) | |
| 1 |
| 2 /* |
| 3 * Copyright 2016 Google Inc. |
| 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. |
| 7 */ |
| 8 |
| 9 #include "RasterWindowContext.h" |
| 10 |
| 11 #include "SkSurface.h" |
| 12 |
| 13 namespace sk_app { |
| 14 |
| 15 sk_sp<SkSurface> RasterWindowContext::getBackbufferSurface() { |
| 16 if (nullptr == fBackbufferSurface) { |
| 17 fBackbufferSurface = SkSurface::MakeRaster(this->getImageInfo(), 0, null
ptr); |
| 18 } |
| 19 return fBackbufferSurface; |
| 20 } |
| 21 |
| 22 // Somehow, I couldn't make this a field for reuse. |
| 23 // Weird things happen as soon as I declare a SkImageInfo field... |
| 24 SkImageInfo RasterWindowContext::getImageInfo() { |
| 25 return SkImageInfo::Make(fWidth, fHeight, |
| 26 fDisplayParams.fColorType, |
| 27 kOpaque_SkAlphaType, |
| 28 fDisplayParams.fProfileType); |
| 29 } |
| 30 |
| 31 void RasterWindowContext::swapBuffers() { |
| 32 sk_sp<SkImage> image = fBackbufferSurface->makeImageSnapshot(); |
| 33 this->onSwapBuffers(image); |
| 34 fBackbufferSurface.reset(nullptr); |
| 35 } |
| 36 |
| 37 } // namespace sk_app |
OLD | NEW |