66c505f6e8
After sk_imageinfo was initially created, we have added a colorspace to it, and that object is a smart-pointer. In response to that, this CL upgrades imageinfo to an "object" (like paint), so we can manage the ref-counting of its colorspace, and to allow for future changes/expansion (like paint). Bug: skia: Change-Id: I629ff99c0820fdbe83f062d9fb768c15cda68e18 Reviewed-on: https://skia-review.googlesource.com/157156 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
63 lines
1.8 KiB
C
63 lines
1.8 KiB
C
/*
|
|
* Copyright 2018 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
|
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
|
|
|
#ifndef sk_imageinfo_DEFINED
|
|
#define sk_imageinfo_DEFINED
|
|
|
|
#include "sk_types.h"
|
|
|
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
|
|
|
typedef enum {
|
|
UNKNOWN_SK_COLORTYPE,
|
|
RGBA_8888_SK_COLORTYPE,
|
|
BGRA_8888_SK_COLORTYPE,
|
|
ALPHA_8_SK_COLORTYPE,
|
|
GRAY_8_SK_COLORTYPE,
|
|
RGBA_F16_SK_COLORTYPE,
|
|
RGBA_F32_SK_COLORTYPE,
|
|
} sk_colortype_t;
|
|
|
|
typedef enum {
|
|
OPAQUE_SK_ALPHATYPE,
|
|
PREMUL_SK_ALPHATYPE,
|
|
UNPREMUL_SK_ALPHATYPE,
|
|
} sk_alphatype_t;
|
|
|
|
/**
|
|
* Allocate a new imageinfo object. If colorspace is not null, it's owner-count will be
|
|
* incremented automatically.
|
|
*/
|
|
sk_imageinfo_t* sk_imageinfo_new(int width, int height, sk_colortype_t ct, sk_alphatype_t at,
|
|
sk_colorspace_t* cs);
|
|
|
|
/**
|
|
* Free the imageinfo object. If it contains a reference to a colorspace, its owner-count will
|
|
* be decremented automatically.
|
|
*/
|
|
void sk_imageinfo_delete(sk_imageinfo_t*);
|
|
|
|
int32_t sk_imageinfo_get_width(sk_imageinfo_t*);
|
|
int32_t sk_imageinfo_get_height(sk_imageinfo_t*);
|
|
sk_colortype_t sk_imageinfo_get_colortype(sk_imageinfo_t*);
|
|
sk_alphatype_t sk_imageinfo_get_alphatype(sk_imageinfo_t*);
|
|
|
|
/**
|
|
* Return the colorspace object reference contained in the imageinfo, or null if there is none.
|
|
* Note: this does not modify the owner-count on the colorspace object. If the caller needs to
|
|
* use the colorspace beyond the lifetime of the imageinfo, it should manually call
|
|
* sk_colorspace_ref() (and then call unref() when it is done).
|
|
*/
|
|
sk_colorspace_t* sk_imageinfo_get_colorspace(sk_imageinfo_t*);
|
|
|
|
SK_C_PLUS_PLUS_END_GUARD
|
|
|
|
#endif
|