29 MakeEnumName(SDL_GPU_BLENDFACTOR_ZERO),
30 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE),
31 MakeEnumName(SDL_GPU_BLENDFACTOR_SRC_COLOR),
32 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR),
33 MakeEnumName(SDL_GPU_BLENDFACTOR_DST_COLOR),
34 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR),
35 MakeEnumName(SDL_GPU_BLENDFACTOR_SRC_ALPHA),
36 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA),
37 MakeEnumName(SDL_GPU_BLENDFACTOR_DST_ALPHA),
38 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA),
39 MakeEnumName(SDL_GPU_BLENDFACTOR_CONSTANT_COLOR),
40 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR),
41 MakeEnumName(SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE)
44#define _Class _ImageView
57 this->texture = release(this->texture);
80 $(self, bind, inlets, dictionary);
99 if (this->texture == NULL) {
101 this->texture = $(renderer->
device, createTextureFromSurface,
102 this->image->surface, SDL_GPU_TEXTUREUSAGE_SAMPLER,
false);
103 assert(this->texture);
112 $(renderer,
drawTexture, this->texture, &frame, &this->color);
123 this->texture = release(this->texture);
128#pragma mark - ImageView
138 self->
blend.
src = SDL_GPU_BLENDFACTOR_SRC_ALPHA;
139 self->
blend.
dst = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
167 release(self->
image);
170 self->
image = retain(image);
173 const SDL_Size imageSize = $(image,
size);
204 Resource *resource = $$(Resource, resourceWithName, name);
229#pragma mark - Class lifecycle
236 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
239 ((ViewInterface *) clazz->interface)->init =
init;
243 ((ImageViewInterface *) clazz->interface)->initWithFrame =
initWithFrame;
260 clazz = _initialize(&(
const ClassDef) {
262 .superclass =
_View(),
264 .interfaceOffset = offsetof(
ImageView, interface),
265 .interfaceSize =
sizeof(ImageViewInterface),
static Image * imageWithResource(const Resource *resource)
static Image * initWithSurface(Image *self, SDL_Surface *surface)
static SDL_Size size(const Image *self)
static void setImageWithResource(ImageView *self, const Resource *resource)
static void setImageWithSurface(ImageView *self, SDL_Surface *surface)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static ImageView * initWithFrame(ImageView *self, const SDL_Rect *frame)
static void setImageWithResourceName(ImageView *self, const char *name)
static void setImage(ImageView *self, Image *image)
static void render(View *self, Renderer *renderer)
static ImageView * initWithImage(ImageView *self, Image *image)
static void dealloc(Object *self)
const EnumName SDLGPUBlendFactorNames[]
static void initialize(Class *clazz)
static void renderDeviceWillReset(View *self)
ImageViews render an Image in the context of a View hierarchy.
static void drawTexture(const Renderer *self, Texture *texture, const SDL_Rect *rect, const SDL_Color *color)
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static void resize(View *self, const SDL_Size *size)
static SDL_Rect renderFrame(const View *self)
ImageViews render an Image in the context of a View hierarchy.
void setImage(ImageView *self, Image *image)
Sets the Image for this ImageView.
Texture * texture
The GPU texture.
ImageView * initWithImage(ImageView *self, const SDL_Rect *frame)
SDL_Color color
The drawing color.
struct ImageView::@0 blend
The blend factors (currently unused; reserved for future per-pipeline support).
Inlets enable inbound data binding of View attributes through JSON.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
RenderDevice * device
The backing RenderDevice.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
void render(View *self, Renderer *renderer)
Renders this View using the given renderer.