OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "RasterWindowContext_android.h" | 9 #include "RasterWindowContext_android.h" |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 fHeight = h; | 60 fHeight = h; |
61 this->setBuffersGeometry(); | 61 this->setBuffersGeometry(); |
62 } | 62 } |
63 | 63 |
64 sk_sp<SkSurface> RasterWindowContext_android::getBackbufferSurface() { | 64 sk_sp<SkSurface> RasterWindowContext_android::getBackbufferSurface() { |
65 if (nullptr == fBackbufferSurface) { | 65 if (nullptr == fBackbufferSurface) { |
66 ANativeWindow_lock(fNativeWindow, &fBuffer, &fBounds); | 66 ANativeWindow_lock(fNativeWindow, &fBuffer, &fBounds); |
67 const int bytePerPixel = fBuffer.format == WINDOW_FORMAT_RGB_565 ? 2 : 4
; | 67 const int bytePerPixel = fBuffer.format == WINDOW_FORMAT_RGB_565 ? 2 : 4
; |
68 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, | 68 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, |
69 fDisplayParams.fColorType, | 69 fDisplayParams.fColorType, |
70 kOpaque_SkAlphaType, | 70 kPremul_SkAlphaType, |
71 fDisplayParams.fColorSpace); | 71 fDisplayParams.fColorSpace); |
72 fBackbufferSurface = SkSurface::MakeRasterDirect( | 72 fBackbufferSurface = SkSurface::MakeRasterDirect( |
73 info, fBuffer.bits, fBuffer.stride * bytePerPixel, nullptr); | 73 info, fBuffer.bits, fBuffer.stride * bytePerPixel, nullptr); |
74 } | 74 } |
75 return fBackbufferSurface; | 75 return fBackbufferSurface; |
76 } | 76 } |
77 | 77 |
78 | 78 |
79 void RasterWindowContext_android::swapBuffers() { | 79 void RasterWindowContext_android::swapBuffers() { |
80 ANativeWindow_unlockAndPost(fNativeWindow); | 80 ANativeWindow_unlockAndPost(fNativeWindow); |
81 fBackbufferSurface.reset(nullptr); | 81 fBackbufferSurface.reset(nullptr); |
82 } | 82 } |
83 | 83 |
84 } // namespace sk_app | 84 } // namespace sk_app |
OLD | NEW |