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 
11 #include "GrTextureProxy.h"
12 #include "GrTypesPriv.h"
13 
14 namespace sk_gpu_test {
15 
16 /** Makes a texture proxy containing the passed in color data. */
17 sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width, int height,
18                                                GrColorType, GrSRGBEncoded, GrSurfaceOrigin,
19                                                const void* data, size_t rowBytes);
20 
21 /** Version that assumes GrSRGBEncoded::kNo. */
MakeTextureProxyFromData(GrContext * context,bool isRT,int width,int height,GrColorType ct,GrSurfaceOrigin origin,const void * data,size_t rowBytes)22 inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width,
23                                                       int height, GrColorType ct,
24                                                       GrSurfaceOrigin origin, const void* data,
25                                                       size_t rowBytes) {
26     return MakeTextureProxyFromData(context, isRT, width, height, ct, GrSRGBEncoded::kNo, origin,
27                                     data, rowBytes);
28 }
29 
30 /** Version that takes SkColorType rather than GrColorType and assumes GrSRGBEncoded::kNo. */
MakeTextureProxyFromData(GrContext * context,bool isRT,int width,int height,SkColorType ct,GrSurfaceOrigin origin,const void * data,size_t rowBytes)31 inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width,
32                                                       int height, SkColorType ct,
33                                                       GrSurfaceOrigin origin, const void* data,
34                                                       size_t rowBytes) {
35     return MakeTextureProxyFromData(context, isRT, width, height, SkColorTypeToGrColorType(ct),
36                                     origin, data, rowBytes);
37 }
38 
39 }  // namespace sk_gpu_test
40 
41 #endif
42