Ignore:
Timestamp:
Nov 25, 2007, 3:12:01 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Introduce cucul_get_canvas_chars() and cucul_get_canvas_attrs() to avoid direct cv->chars and cv->attrs access by display drivers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_cocoa.m

    r2055 r2056  
    2424#import <Cocoa/Cocoa.h>
    2525
     26#include "cucul.h"
    2627#include "caca.h"
    2728#include "caca_internals.h"
    28 #include "cucul.h"
    29 #include "cucul_internals.h"
    3029
    3130//#define COCOA_DEBUG
     
    197196- (void)resizeIfNeeded:(caca_display_t *)dp
    198197{
    199     if(   _w != dp->cv->width || _h != dp->cv->height
    200        || !_attrs || !_bkg_rects || !_bkg_colors)
     198    if(_w != cucul_get_canvas_width(dp->cv)
     199        || _h != cucul_get_canvas_height(dp->cv)
     200        || !_attrs || !_bkg_rects || !_bkg_colors)
    201201    {
    202202        debug_log(@"%s resize to %ux%u", _cmd, _w, _h);
    203203       
    204         _w = dp->cv->width;
    205         _h = dp->cv->height;
     204        _w = cucul_get_canvas_width(dp->cv);
     205        _h = cucul_get_canvas_height(dp->cv);
    206206
    207207        if(_attrs)
     
    217217        _bkg_colors = malloc(_w * _h * sizeof(NSColor*));
    218218
    219         [[self window] setContentSize: NSMakeSize(dp->cv->width * _font_rect.size.width,
    220                                                   dp->cv->height * _font_rect.size.height)];
     219        [[self window] setContentSize: NSMakeSize(cucul_get_canvas_width(dp->cv) * _font_rect.size.width,
     220                                                  cucul_get_canvas_height(dp->cv) * _font_rect.size.height)];
    221221    }
    222222}
     
    229229    {
    230230        _chars = _attrs + _w * _h;
    231         memcpy(_attrs, dp->cv->attrs, _w * _h * sizeof(uint32_t));
    232         memcpy(_chars, dp->cv->chars, _w * _h * sizeof(uint32_t));
     231        memcpy(_attrs, cucul_get_canvas_attrs(dp->cv),
     232               _w * _h * sizeof(uint32_t));
     233        memcpy(_chars, cucul_get_canvas_chars(dp->cv),
     234               _w * _h * sizeof(uint32_t));
    233235
    234236        [self setNeedsDisplay:TRUE];
     
    571573    NSRect fontRect = [font boundingRectForFont];
    572574    fontRect = NSMakeRect(0, 0, ceilf(fontRect.size.width), ceilf(fontRect.size.height));
    573     NSRect windowRect = NSMakeRect(20, 20, dp->cv->width * fontRect.size.width,
    574                                            dp->cv->height * fontRect.size.height);
     575    NSRect windowRect = NSMakeRect(20, 20, cucul_get_canvas_width(dp->cv) * fontRect.size.width,
     576                                           cucul_get_canvas_height(dp->cv) * fontRect.size.height);
    575577    convert_NSRect(&windowRect);
    576578
     
    825827static int cocoa_init_graphics(caca_display_t *dp)
    826828{
    827     debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__,
    828               dp->cv->width, dp->cv->height);
     829    unsigned int width = cucul_get_canvas_width(dp->cv);
     830    unsigned int height = cucul_get_canvas_height(dp->cv);
     831
     832    debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, width, height);
    829833
    830834    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     
    834838        return -1;
    835839
    836     unsigned int width = dp->cv->width, height = dp->cv->height;
    837840    dp->resize.allow = 1;
    838841    cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
     
    856859{
    857860    debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__,
    858               dp->cv->width, dp->cv->height);
     861              cucul_get_canvas_width(dp->cv), cucul_get_canvas_height(dp->cv));
    859862
    860863    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     
    956959{
    957960    debug_log(@"%s", __PRETTY_FUNCTION__);
    958     dp->resize.w = dp->cv->width;
    959     dp->resize.h = dp->cv->height;
     961    dp->resize.w = cucul_get_canvas_width(dp->cv);
     962    dp->resize.h = cucul_get_canvas_height(dp->cv);
    960963}
    961964
Note: See TracChangeset for help on using the changeset viewer.