ProxyUtils.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. #ifndef ProxyUtils_DEFINED
  8. #define ProxyUtils_DEFINED
  9. #include "include/private/GrTypesPriv.h"
  10. #include "src/gpu/GrTextureProxy.h"
  11. namespace sk_gpu_test {
  12. /** Makes a texture proxy containing the passed in color data. */
  13. sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext*, GrRenderable, int width, int height,
  14. GrColorType, SkAlphaType, GrSurfaceOrigin,
  15. const void* data, size_t rowBytes);
  16. /** Version that takes SkColorType rather than GrColorType. */
  17. inline sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, GrRenderable renderable,
  18. int width, int height, SkColorType ct,
  19. SkAlphaType alphaType, GrSurfaceOrigin origin,
  20. const void* data, size_t rowBytes) {
  21. GrColorType grCT = SkColorTypeToGrColorType(ct);
  22. if (GrColorType::kUnknown == grCT) {
  23. return nullptr;
  24. }
  25. return MakeTextureProxyFromData(context, renderable, width, height, grCT, alphaType, origin,
  26. data, rowBytes);
  27. }
  28. } // namespace sk_gpu_test
  29. #endif