blob: 75280c5665a56029064bf7d559a850774abad36a [file] [log] [blame]
Brian Salomon58389b92018-03-07 13:01:25 -05001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/GrTypesPriv.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040012#include "src/gpu/GrTextureProxy.h"
Brian Salomon58389b92018-03-07 13:01:25 -050013
14namespace sk_gpu_test {
15
16/** Makes a texture proxy containing the passed in color data. */
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040017sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext*, GrRenderable, int width, int height,
Brian Salomon58389b92018-03-07 13:01:25 -050018 GrColorType, GrSRGBEncoded, GrSurfaceOrigin,
19 const void* data, size_t rowBytes);
20
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040021/** Version that takes GrColorType rather than SkColorType and assumes GrSRGBEncoded::kNo. */
Robert Phillips69893702019-02-22 11:16:30 -050022inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context,
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040023 GrRenderable renderable, int width,
24 int height, GrColorType grCT,
Brian Salomon58389b92018-03-07 13:01:25 -050025 GrSurfaceOrigin origin, const void* data,
26 size_t rowBytes) {
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040027 return MakeTextureProxyFromData(context, renderable, width, height,
28 grCT, GrSRGBEncoded::kNo, origin, data, rowBytes);
Brian Salomon58389b92018-03-07 13:01:25 -050029}
30
31/** Version that takes SkColorType rather than GrColorType and assumes GrSRGBEncoded::kNo. */
Robert Phillips69893702019-02-22 11:16:30 -050032inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context,
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040033 GrRenderable renderable, int width,
Brian Salomon58389b92018-03-07 13:01:25 -050034 int height, SkColorType ct,
35 GrSurfaceOrigin origin, const void* data,
36 size_t rowBytes) {
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040037 GrColorType grCT = SkColorTypeToGrColorType(ct);
38 if (GrColorType::kUnknown == grCT) {
39 return nullptr;
40 }
41
42 return MakeTextureProxyFromData(context, renderable, width, height,
43 grCT, GrSRGBEncoded::kNo, origin, data, rowBytes);
Brian Salomon58389b92018-03-07 13:01:25 -050044}
45
46} // namespace sk_gpu_test
47
48#endif