mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-20 11:12:46 +03:00
Fix several warnings in cocoa frontend
This commit is contained in:
parent
e1bbe4528b
commit
9c6b3e8c32
@ -20,6 +20,7 @@
|
|||||||
#import "cocoa/gui.h"
|
#import "cocoa/gui.h"
|
||||||
|
|
||||||
#import "utils/log.h"
|
#import "utils/log.h"
|
||||||
|
#import "utils/nsurl.h"
|
||||||
#import "desktop/download.h"
|
#import "desktop/download.h"
|
||||||
#import "desktop/gui_download.h"
|
#import "desktop/gui_download.h"
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
#ifdef WITH_APPLE_IMAGE
|
#ifdef WITH_APPLE_IMAGE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise apple image handlers instead of generic core ones.
|
||||||
|
*/
|
||||||
nserror apple_image_init(void);
|
nserror apple_image_init(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
* NetSurf is distributed in the hope that it will be useful,
|
* NetSurf is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
@ -26,29 +26,19 @@
|
|||||||
#include "desktop/plotters.h"
|
#include "desktop/plotters.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
#include "cocoa/schedule.h"
|
#import "cocoa/schedule.h"
|
||||||
|
#import "cocoa/bitmap.h"
|
||||||
|
|
||||||
typedef struct apple_image_content {
|
typedef struct apple_image_content {
|
||||||
struct content base;
|
struct content base;
|
||||||
|
|
||||||
struct bitmap *bitmap; /**< Created NetSurf bitmap */
|
struct bitmap *bitmap; /**< Created NetSurf bitmap */
|
||||||
|
|
||||||
NSUInteger frames;
|
NSUInteger frames;
|
||||||
NSUInteger currentFrame;
|
NSUInteger currentFrame;
|
||||||
int *frameTimes;
|
int *frameTimes;
|
||||||
} apple_image_content;
|
} apple_image_content;
|
||||||
|
|
||||||
static nserror apple_image_create(const content_handler *handler,
|
|
||||||
lwc_string *imime_type, const http_parameter *params,
|
|
||||||
llcache_handle *llcache, const char *fallback_charset,
|
|
||||||
bool quirks, struct content **c);
|
|
||||||
static bool apple_image_convert(struct content *c);
|
|
||||||
static void apple_image_destroy(struct content *c);
|
|
||||||
static bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
|
|
||||||
const struct rect *clip, const struct redraw_context *ctx);
|
|
||||||
static nserror apple_image_clone(const struct content *old,
|
|
||||||
struct content **newc);
|
|
||||||
static content_type apple_image_content_type(void);
|
|
||||||
|
|
||||||
static void *apple_image_get_internal(const struct content *c, void *context)
|
static void *apple_image_get_internal(const struct content *c, void *context)
|
||||||
{
|
{
|
||||||
@ -57,55 +47,7 @@ static void *apple_image_get_internal(const struct content *c, void *context)
|
|||||||
return ai_c->bitmap;
|
return ai_c->bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const content_handler apple_image_content_handler = {
|
static nserror apple_image_create(const content_handler *handler,
|
||||||
.create = apple_image_create,
|
|
||||||
.data_complete = apple_image_convert,
|
|
||||||
.destroy = apple_image_destroy,
|
|
||||||
.redraw = apple_image_redraw,
|
|
||||||
.clone = apple_image_clone,
|
|
||||||
.get_internal = apple_image_get_internal,
|
|
||||||
.type = apple_image_content_type,
|
|
||||||
.no_share = false
|
|
||||||
};
|
|
||||||
|
|
||||||
static nserror register_for_type( NSString *mime )
|
|
||||||
{
|
|
||||||
const char *type = [mime UTF8String];
|
|
||||||
/* nsgif has priority since it supports animated GIF */
|
|
||||||
#ifdef WITH_GIF
|
|
||||||
if (strcmp(type, "image/gif") == 0)
|
|
||||||
return NSERROR_OK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nserror error = content_factory_register_handler( type, &apple_image_content_handler );
|
|
||||||
if (error != NSERROR_OK) return error;
|
|
||||||
|
|
||||||
return NSERROR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nserror apple_image_init(void)
|
|
||||||
{
|
|
||||||
NSArray *utis = [NSBitmapImageRep imageTypes];
|
|
||||||
for (NSString *uti in utis) {
|
|
||||||
NSDictionary *declaration = [(NSDictionary *)UTTypeCopyDeclaration( (CFStringRef)uti ) autorelease];
|
|
||||||
id mimeTypes = [[declaration objectForKey: (NSString *)kUTTypeTagSpecificationKey] objectForKey: (NSString *)kUTTagClassMIMEType];
|
|
||||||
|
|
||||||
if (mimeTypes == nil) continue;
|
|
||||||
|
|
||||||
if (![mimeTypes isKindOfClass: [NSArray class]]) {
|
|
||||||
mimeTypes = [NSArray arrayWithObject: mimeTypes];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NSString *mime in mimeTypes) {
|
|
||||||
nserror error = register_for_type( mime );
|
|
||||||
if (error != NSERROR_OK) return error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NSERROR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nserror apple_image_create(const content_handler *handler,
|
|
||||||
lwc_string *imime_type, const http_parameter *params,
|
lwc_string *imime_type, const http_parameter *params,
|
||||||
llcache_handle *llcache, const char *fallback_charset,
|
llcache_handle *llcache, const char *fallback_charset,
|
||||||
bool quirks, struct content **c)
|
bool quirks, struct content **c)
|
||||||
@ -132,30 +74,29 @@ nserror apple_image_create(const content_handler *handler,
|
|||||||
|
|
||||||
static void animate_image_cb( void *ptr )
|
static void animate_image_cb( void *ptr )
|
||||||
{
|
{
|
||||||
struct apple_image_content *ai = ptr;
|
struct apple_image_content *ai = ptr;
|
||||||
++ai->currentFrame;
|
++ai->currentFrame;
|
||||||
if (ai->currentFrame >= ai->frames) ai->currentFrame = 0;
|
if (ai->currentFrame >= ai->frames) ai->currentFrame = 0;
|
||||||
|
|
||||||
[(NSBitmapImageRep *)ai->bitmap setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: ai->currentFrame]];
|
|
||||||
bitmap_modified( ai->bitmap );
|
|
||||||
|
|
||||||
union content_msg_data data;
|
|
||||||
data.redraw.full_redraw = true;
|
|
||||||
data.redraw.x = data.redraw.object_x = 0;
|
|
||||||
data.redraw.y = data.redraw.object_y = 0;
|
|
||||||
data.redraw.width = data.redraw.object_width = ai->base.width;
|
|
||||||
data.redraw.height = data.redraw.object_height = ai->base.height;
|
|
||||||
data.redraw.object = &ai->base;
|
|
||||||
content_broadcast( &ai->base, CONTENT_MSG_REDRAW, data );
|
|
||||||
|
|
||||||
cocoa_schedule(ai->frameTimes[ai->currentFrame], animate_image_cb, ai );
|
[(NSBitmapImageRep *)ai->bitmap setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: ai->currentFrame]];
|
||||||
|
cocoa_bitmap_modified( ai->bitmap );
|
||||||
|
|
||||||
|
union content_msg_data data;
|
||||||
|
data.redraw.full_redraw = true;
|
||||||
|
data.redraw.x = data.redraw.object_x = 0;
|
||||||
|
data.redraw.y = data.redraw.object_y = 0;
|
||||||
|
data.redraw.width = data.redraw.object_width = ai->base.width;
|
||||||
|
data.redraw.height = data.redraw.object_height = ai->base.height;
|
||||||
|
data.redraw.object = &ai->base;
|
||||||
|
content_broadcast( &ai->base, CONTENT_MSG_REDRAW, data );
|
||||||
|
|
||||||
|
cocoa_schedule(ai->frameTimes[ai->currentFrame], animate_image_cb, ai );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a CONTENT_APPLE_IMAGE for display.
|
* Convert a CONTENT_APPLE_IMAGE for display.
|
||||||
*/
|
*/
|
||||||
|
static bool apple_image_convert(struct content *c)
|
||||||
bool apple_image_convert(struct content *c)
|
|
||||||
{
|
{
|
||||||
apple_image_content *ai_c = (apple_image_content *)c;
|
apple_image_content *ai_c = (apple_image_content *)c;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
@ -170,7 +111,7 @@ bool apple_image_convert(struct content *c)
|
|||||||
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->width = [image pixelsWide];
|
c->width = [image pixelsWide];
|
||||||
c->height = [image pixelsHigh];
|
c->height = [image pixelsHigh];
|
||||||
ai_c->bitmap = (void *)image;
|
ai_c->bitmap = (void *)image;
|
||||||
@ -178,40 +119,40 @@ bool apple_image_convert(struct content *c)
|
|||||||
NSString *url = [NSString stringWithUTF8String: nsurl_access(llcache_handle_get_url( content_get_llcache_handle( c )) )];
|
NSString *url = [NSString stringWithUTF8String: nsurl_access(llcache_handle_get_url( content_get_llcache_handle( c )) )];
|
||||||
NSString *title = [NSString stringWithFormat: @"%@ (%dx%d)", [url lastPathComponent], c->width, c->height];
|
NSString *title = [NSString stringWithFormat: @"%@ (%dx%d)", [url lastPathComponent], c->width, c->height];
|
||||||
content__set_title(c, [title UTF8String] );
|
content__set_title(c, [title UTF8String] );
|
||||||
|
|
||||||
content_set_ready(c);
|
content_set_ready(c);
|
||||||
content_set_done(c);
|
content_set_done(c);
|
||||||
content_set_status(c, "");
|
content_set_status(c, "");
|
||||||
|
|
||||||
struct apple_image_content *ai = (struct apple_image_content *)c;
|
struct apple_image_content *ai = (struct apple_image_content *)c;
|
||||||
NSUInteger frames = [[image valueForProperty: NSImageFrameCount] unsignedIntegerValue];
|
NSUInteger frames = [[image valueForProperty: NSImageFrameCount] unsignedIntegerValue];
|
||||||
if (frames > 1) {
|
if (frames > 1) {
|
||||||
ai->frames = frames;
|
ai->frames = frames;
|
||||||
ai->currentFrame = 0;
|
ai->currentFrame = 0;
|
||||||
ai->frameTimes = calloc( ai->frames , sizeof(int));
|
ai->frameTimes = calloc( ai->frames , sizeof(int));
|
||||||
for (NSUInteger i = 0; i < frames; i++) {
|
for (NSUInteger i = 0; i < frames; i++) {
|
||||||
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: i]];
|
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: i]];
|
||||||
ai->frameTimes[i] = 1000 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue];
|
ai->frameTimes[i] = 1000 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue];
|
||||||
}
|
}
|
||||||
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: 0]];
|
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: 0]];
|
||||||
cocoa_schedule( ai->frameTimes[0], animate_image_cb, ai );
|
cocoa_schedule( ai->frameTimes[0], animate_image_cb, ai );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void apple_image_destroy(struct content *c)
|
static void apple_image_destroy(struct content *c)
|
||||||
{
|
{
|
||||||
apple_image_content *ai_c = (apple_image_content *)c;
|
apple_image_content *ai_c = (apple_image_content *)c;
|
||||||
|
|
||||||
[(id)ai_c->bitmap release];
|
[(id)ai_c->bitmap release];
|
||||||
ai_c->bitmap = NULL;
|
ai_c->bitmap = NULL;
|
||||||
cocoa_schedule(-1, animate_image_cb, c );
|
cocoa_schedule(-1, animate_image_cb, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nserror apple_image_clone(const struct content *old, struct content **newc)
|
static nserror apple_image_clone(const struct content *old, struct content **newc)
|
||||||
{
|
{
|
||||||
apple_image_content *ai;
|
apple_image_content *ai;
|
||||||
apple_image_content *ai_old = (apple_image_content *)old;
|
apple_image_content *ai_old = (apple_image_content *)old;
|
||||||
@ -235,11 +176,11 @@ nserror apple_image_clone(const struct content *old, struct content **newc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*newc = (struct content *) ai;
|
*newc = (struct content *) ai;
|
||||||
|
|
||||||
return NSERROR_OK;
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
content_type apple_image_content_type(void)
|
static content_type apple_image_content_type(void)
|
||||||
{
|
{
|
||||||
return CONTENT_IMAGE;
|
return CONTENT_IMAGE;
|
||||||
}
|
}
|
||||||
@ -247,8 +188,7 @@ content_type apple_image_content_type(void)
|
|||||||
/**
|
/**
|
||||||
* Redraw a CONTENT_APPLE_IMAGE with appropriate tiling.
|
* Redraw a CONTENT_APPLE_IMAGE with appropriate tiling.
|
||||||
*/
|
*/
|
||||||
|
static bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
|
||||||
bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
|
|
||||||
const struct rect *clip, const struct redraw_context *ctx)
|
const struct rect *clip, const struct redraw_context *ctx)
|
||||||
{
|
{
|
||||||
apple_image_content *ai_c = (apple_image_content *)c;
|
apple_image_content *ai_c = (apple_image_content *)c;
|
||||||
@ -263,4 +203,53 @@ bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
|
|||||||
ai_c->bitmap, data->background_colour, flags);
|
ai_c->bitmap, data->background_colour, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const content_handler apple_image_content_handler = {
|
||||||
|
.create = apple_image_create,
|
||||||
|
.data_complete = apple_image_convert,
|
||||||
|
.destroy = apple_image_destroy,
|
||||||
|
.redraw = apple_image_redraw,
|
||||||
|
.clone = apple_image_clone,
|
||||||
|
.get_internal = apple_image_get_internal,
|
||||||
|
.type = apple_image_content_type,
|
||||||
|
.no_share = false
|
||||||
|
};
|
||||||
|
|
||||||
|
static nserror register_for_type( NSString *mime )
|
||||||
|
{
|
||||||
|
const char *type = [mime UTF8String];
|
||||||
|
/* nsgif has priority since it supports animated GIF */
|
||||||
|
#ifdef WITH_GIF
|
||||||
|
if (strcmp(type, "image/gif") == 0)
|
||||||
|
return NSERROR_OK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nserror error = content_factory_register_handler( type, &apple_image_content_handler );
|
||||||
|
if (error != NSERROR_OK) return error;
|
||||||
|
|
||||||
|
return NSERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* exported interface documented in cocoa/apple_image.h */
|
||||||
|
nserror apple_image_init(void)
|
||||||
|
{
|
||||||
|
NSArray *utis = [NSBitmapImageRep imageTypes];
|
||||||
|
for (NSString *uti in utis) {
|
||||||
|
NSDictionary *declaration = [(NSDictionary *)UTTypeCopyDeclaration( (CFStringRef)uti ) autorelease];
|
||||||
|
id mimeTypes = [[declaration objectForKey: (NSString *)kUTTypeTagSpecificationKey] objectForKey: (NSString *)kUTTagClassMIMEType];
|
||||||
|
|
||||||
|
if (mimeTypes == nil) continue;
|
||||||
|
|
||||||
|
if (![mimeTypes isKindOfClass: [NSArray class]]) {
|
||||||
|
mimeTypes = [NSArray arrayWithObject: mimeTypes];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NSString *mime in mimeTypes) {
|
||||||
|
nserror error = register_for_type( mime );
|
||||||
|
if (error != NSERROR_OK) return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NSERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* WITH_APPLE_IMAGE */
|
#endif /* WITH_APPLE_IMAGE */
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
CGImageRef cocoa_get_cgimage( void *bitmap );
|
CGImageRef cocoa_get_cgimage( void *bitmap );
|
||||||
|
|
||||||
|
void cocoa_bitmap_modified(void *bitmap);
|
||||||
|
|
||||||
struct gui_bitmap_table *cocoa_bitmap_table;
|
struct gui_bitmap_table *cocoa_bitmap_table;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
* NetSurf is distributed in the hope that it will be useful,
|
* NetSurf is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
@ -44,28 +44,28 @@
|
|||||||
static CGImageRef cocoa_prepare_bitmap( void *bitmap );
|
static CGImageRef cocoa_prepare_bitmap( void *bitmap );
|
||||||
static NSMapTable *cocoa_get_bitmap_cache( void );
|
static NSMapTable *cocoa_get_bitmap_cache( void );
|
||||||
|
|
||||||
int bitmap_get_width(void *bitmap)
|
static int bitmap_get_width(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
return [bmp pixelsWide];
|
return [bmp pixelsWide];
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitmap_get_height(void *bitmap)
|
static int bitmap_get_height(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
return [bmp pixelsHigh];
|
return [bmp pixelsHigh];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bitmap_get_opaque(void *bitmap)
|
static bool bitmap_get_opaque(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
return [bmp isOpaque];
|
return [bmp isOpaque];
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitmap_destroy(void *bitmap)
|
static void bitmap_destroy(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ void bitmap_destroy(void *bitmap)
|
|||||||
[bmp release];
|
[bmp release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void *bitmap_create(int width, int height, unsigned int state)
|
static void *bitmap_create(int width, int height, unsigned int state)
|
||||||
{
|
{
|
||||||
NSBitmapImageRep *bmp = [[NSBitmapImageRep alloc]
|
NSBitmapImageRep *bmp = [[NSBitmapImageRep alloc]
|
||||||
initWithBitmapDataPlanes: NULL
|
initWithBitmapDataPlanes: NULL
|
||||||
@ -98,35 +98,35 @@ void *bitmap_create(int width, int height, unsigned int state)
|
|||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitmap_set_opaque(void *bitmap, bool opaque)
|
static void bitmap_set_opaque(void *bitmap, bool opaque)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
[bmp setOpaque: opaque ? YES : NO];
|
[bmp setOpaque: opaque ? YES : NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *bitmap_get_buffer(void *bitmap)
|
static unsigned char *bitmap_get_buffer(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
return [bmp bitmapData];
|
return [bmp bitmapData];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bitmap_get_rowstride(void *bitmap)
|
static size_t bitmap_get_rowstride(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
return [bmp bytesPerRow];
|
return [bmp bytesPerRow];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bitmap_get_bpp(void *bitmap)
|
static size_t bitmap_get_bpp(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
return [bmp bitsPerPixel] / 8;
|
return [bmp bitsPerPixel] / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bitmap_test_opaque(void *bitmap)
|
static bool bitmap_test_opaque(void *bitmap)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( bitmap_get_bpp( bitmap ) == BYTES_PER_PIXEL );
|
NSCParameterAssert( bitmap_get_bpp( bitmap ) == BYTES_PER_PIXEL );
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ bool bitmap_test_opaque(void *bitmap)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bitmap_save(void *bitmap, const char *path, unsigned flags)
|
static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
|
||||||
{
|
{
|
||||||
NSCParameterAssert( NULL != bitmap );
|
NSCParameterAssert( NULL != bitmap );
|
||||||
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
|
||||||
@ -157,7 +157,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
|
|||||||
return [tiff writeToFile: [NSString stringWithUTF8String: path] atomically: YES];
|
return [tiff writeToFile: [NSString stringWithUTF8String: path] atomically: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitmap_modified(void *bitmap)
|
static void cocoa_bitmap_modified(void *bitmap)
|
||||||
{
|
{
|
||||||
NSMapTable *cache = cocoa_get_bitmap_cache();
|
NSMapTable *cache = cocoa_get_bitmap_cache();
|
||||||
CGImageRef image = NSMapGet( cache, bitmap );
|
CGImageRef image = NSMapGet( cache, bitmap );
|
||||||
@ -258,7 +258,7 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
|
|||||||
[NSGraphicsContext setCurrentContext: nil];
|
[NSGraphicsContext setCurrentContext: nil];
|
||||||
CGContextRelease( bitmapContext );
|
CGContextRelease( bitmapContext );
|
||||||
|
|
||||||
bitmap_modified( bitmap );
|
cocoa_bitmap_modified( bitmap );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ static struct gui_bitmap_table bitmap_table = {
|
|||||||
.get_height = bitmap_get_height,
|
.get_height = bitmap_get_height,
|
||||||
.get_bpp = bitmap_get_bpp,
|
.get_bpp = bitmap_get_bpp,
|
||||||
.save = bitmap_save,
|
.save = bitmap_save,
|
||||||
.modified = bitmap_modified,
|
.modified = cocoa_bitmap_modified,
|
||||||
.render = bitmap_render,
|
.render = bitmap_render,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user