Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef ProxyUtils_DEFINED |
| 9 | #define ProxyUtils_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/private/GrTypesPriv.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrTextureProxy.h" |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 13 | |
| 14 | namespace sk_gpu_test { |
| 15 | |
| 16 | /** Makes a texture proxy containing the passed in color data. */ |
Robert Phillips | 9dbcdcc | 2019-05-13 10:40:06 -0400 | [diff] [blame] | 17 | sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext*, GrRenderable, int width, int height, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 18 | GrColorType, SkAlphaType, GrSRGBEncoded, |
| 19 | GrSurfaceOrigin, const void* data, size_t rowBytes); |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 20 | |
Robert Phillips | 9dbcdcc | 2019-05-13 10:40:06 -0400 | [diff] [blame] | 21 | /** Version that takes GrColorType rather than SkColorType and assumes GrSRGBEncoded::kNo. */ |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 22 | inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, GrRenderable renderable, |
| 23 | int width, int height, GrColorType grCT, |
| 24 | SkAlphaType alphaType, GrSurfaceOrigin origin, |
| 25 | const void* data, size_t rowBytes) { |
| 26 | return MakeTextureProxyFromData(context, renderable, width, height, grCT, alphaType, |
| 27 | GrSRGBEncoded::kNo, origin, data, rowBytes); |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | /** Version that takes SkColorType rather than GrColorType and assumes GrSRGBEncoded::kNo. */ |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 31 | inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, GrRenderable renderable, |
| 32 | int width, int height, SkColorType ct, |
| 33 | SkAlphaType alphaType, GrSurfaceOrigin origin, |
| 34 | const void* data, size_t rowBytes) { |
Robert Phillips | 9dbcdcc | 2019-05-13 10:40:06 -0400 | [diff] [blame] | 35 | GrColorType grCT = SkColorTypeToGrColorType(ct); |
| 36 | if (GrColorType::kUnknown == grCT) { |
| 37 | return nullptr; |
| 38 | } |
| 39 | |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 40 | return MakeTextureProxyFromData(context, renderable, width, height, grCT, alphaType, |
| 41 | GrSRGBEncoded::kNo, origin, data, rowBytes); |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | } // namespace sk_gpu_test |
| 45 | |
| 46 | #endif |