⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agg_platform_support.cpp

📁 gnash 在pc和嵌入式下开发需要的源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb555()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb555()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb555()); break;            }            break;        case pix_format_rgb565:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb565()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb565()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb565()); break;            }            break;        case pix_format_rgb24:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb24()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb24()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb24()); break;            }            break;        case pix_format_bgr24:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr24()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_bgr24()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_bgr24()); break;            }            break;        case pix_format_abgr32:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr32()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_abgr32()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_abgr32()); break;            }            break;        case pix_format_argb32:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb32()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_argb32()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_argb32()); break;            }            break;        case pix_format_bgra32:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra32()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_bgra32()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_bgra32()); break;            }            break;        case pix_format_rgba32:            switch(pmap_tmp.bpp())            {            case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba32()); break;            case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgba32()); break;            case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgba32()); break;            }            break;        }                return true;    }    //------------------------------------------------------------------------    unsigned platform_specific::translate(unsigned keycode)    {        return m_last_translated_key = (keycode > 255) ? 0 : m_keymap[keycode];    }    //------------------------------------------------------------------------    platform_support::platform_support(pix_format_e format, bool flip_y) :        m_specific(new platform_specific(format, flip_y)),        m_format(format),        m_bpp(m_specific->m_bpp),        m_window_flags(0),        m_wait_mode(true),        m_flip_y(flip_y),        m_initial_width(10),        m_initial_height(10)    {        strcpy(m_caption, "Anti-Grain Geometry Application");    }    //------------------------------------------------------------------------    platform_support::~platform_support()    {        delete m_specific;    }    //------------------------------------------------------------------------    void platform_support::caption(const char* cap)    {        strcpy(m_caption, cap);        if(m_specific->m_window)        {        	SetWindowTitleWithCFString (m_specific->m_window, CFStringCreateWithCStringNoCopy (nil, cap, kCFStringEncodingASCII, nil));        }    }    //------------------------------------------------------------------------    static unsigned get_key_flags(UInt32 wflags)    {        unsigned flags = 0;                 if(wflags & shiftKey)   flags |= kbd_shift;         if(wflags & controlKey) flags |= kbd_ctrl;        return flags;    }    //------------------------------------------------------------------------    void platform_support::message(const char* msg)    {		SInt16 item;		Str255 p_msg;				::CopyCStringToPascal (msg, p_msg);		::StandardAlert (kAlertPlainAlert, (const unsigned char*) "\013AGG Message", p_msg, NULL, &item);		//::StandardAlert (kAlertPlainAlert, (const unsigned char*) "\pAGG Message", p_msg, NULL, &item);    }    //------------------------------------------------------------------------    void platform_support::start_timer()    {		::Microseconds (&(m_specific->m_sw_start));    }    //------------------------------------------------------------------------    double platform_support::elapsed_time() const    {        UnsignedWide stop;        ::Microseconds(&stop);        return double(stop.lo -                       m_specific->m_sw_start.lo) * 1e6 /                       double(m_specific->m_sw_freq.lo);    }    //------------------------------------------------------------------------    bool platform_support::init(unsigned width, unsigned height, unsigned flags)    {        if(m_specific->m_sys_format == pix_format_undefined)        {            return false;        }        m_window_flags = flags;		// application		EventTypeSpec		eventType;		EventHandlerUPP		handlerUPP;		eventType.eventClass = kEventClassApplication;		eventType.eventKind = kEventAppQuit;		handlerUPP = NewEventHandlerUPP(DoAppQuit);		InstallApplicationEventHandler (handlerUPP, 1, &eventType, nil, nil);		eventType.eventClass = kEventClassMouse;		eventType.eventKind = kEventMouseDown;		handlerUPP = NewEventHandlerUPP(DoMouseDown);		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);		eventType.eventKind = kEventMouseUp;		handlerUPP = NewEventHandlerUPP(DoMouseUp);		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);				eventType.eventKind = kEventMouseDragged;		handlerUPP = NewEventHandlerUPP(DoMouseDragged);		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);		eventType.eventClass = kEventClassKeyboard;		eventType.eventKind = kEventRawKeyDown;		handlerUPP = NewEventHandlerUPP(DoKeyDown);		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);		eventType.eventKind = kEventRawKeyUp;		handlerUPP = NewEventHandlerUPP(DoKeyUp);		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);		eventType.eventKind = kEventRawKeyRepeat;		handlerUPP = NewEventHandlerUPP(DoKeyDown);		// 'key repeat' is translated to 'key down'		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);		WindowAttributes	windowAttrs;		Rect				bounds;		// window		windowAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute;		SetRect (&bounds, 0, 0, width, height);		OffsetRect (&bounds, 100, 100);		CreateNewWindow (kDocumentWindowClass, windowAttrs, &bounds, &m_specific->m_window);        if(m_specific->m_window == nil)        {            return false;        }		// I assume the text is ASCII.		// Change to kCFStringEncodingMacRoman, kCFStringEncodingISOLatin1, kCFStringEncodingUTF8 or what else you need.        SetWindowTitleWithCFString (m_specific->m_window, CFStringCreateWithCStringNoCopy (nil, m_caption, kCFStringEncodingASCII, nil));				eventType.eventClass = kEventClassWindow;		eventType.eventKind = kEventWindowClose;		handlerUPP = NewEventHandlerUPP(DoWindowClose);		InstallWindowEventHandler (m_specific->m_window, handlerUPP, 1, &eventType, this, NULL);		eventType.eventKind = kEventWindowDrawContent;		handlerUPP = NewEventHandlerUPP(DoWindowDrawContent);		InstallWindowEventHandler (m_specific->m_window, handlerUPP, 1, &eventType, this, NULL);				// Periodic task		// Instead of an idle function I use the Carbon event timer.		// You may decide to change the wait value which is currently 50 milliseconds.		EventLoopRef		mainLoop;		EventLoopTimerUPP	timerUPP;		EventLoopTimerRef	theTimer;		mainLoop = GetMainEventLoop();		timerUPP = NewEventLoopTimerUPP (DoPeriodicTask);		InstallEventLoopTimer (mainLoop, 0, 50 * kEventDurationMillisecond, timerUPP, this, &theTimer);        m_specific->create_pmap(width, height, &m_rbuf_window);        m_initial_width = width;        m_initial_height = height;        on_init();        on_resize(width, height);        m_specific->m_redraw_flag = true;		  		ShowWindow (m_specific->m_window);  		SetPortWindowPort (m_specific->m_window);		      return true;    }    //------------------------------------------------------------------------    int platform_support::run()    {				RunApplicationEventLoop ();        return true;    }    //------------------------------------------------------------------------    const char* platform_support::img_ext() const { return ".bmp"; }    //------------------------------------------------------------------------    const char* platform_support::full_file_name(const char* file_name)    {        return file_name;    }    //------------------------------------------------------------------------    bool platform_support::load_img(unsigned idx, const char* file)    {        if(idx < max_images)        {            char fn[1024];            strcpy(fn, file);            int len = strlen(fn);#if defined(__MWERKS__)            if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0)#else	        if(len < 4 || strncasecmp(fn + len - 4, ".BMP", 4) != 0)#endif            {                strcat(fn, ".bmp");            }            return m_specific->load_pmap(fn, idx, &m_rbuf_img[idx]);        }        return true;    }    //------------------------------------------------------------------------    bool platform_support::save_img(unsigned idx, const char* file)    {        if(idx < max_images)        {            char fn[1024];            strcpy(fn, file);            int len = strlen(fn);#if defined(__MWERKS__)            if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0)#else	        if(len < 4 || strncasecmp(fn + len - 4, ".BMP", 4) != 0)#endif            {                strcat(fn, ".bmp");            }            return m_specific->save_pmap(fn, idx, &m_rbuf_img[idx]);        }        return true;    }    //------------------------------------------------------------------------    bool platform_support::create_img(unsigned idx, unsigned width, unsigned height)    {        if(idx < max_images)        {            if(width  == 0) width  = m_specific->m_pmap_window.width();            if(height == 0) height = m_specific->m_pmap_window.height();            m_specific->m_pmap_img[idx].create(width, height, org_e(m_specific->m_bpp));            m_rbuf_img[idx].attach(m_specific->m_pmap_img[idx].buf(),                                    m_specific->m_pmap_img[idx].width(),                                   m_specific->m_pmap_img[idx].height(),                                   m_flip_y ?                                   -m_specific->m_pmap_img[idx].row_bytes() :                                    m_specific->m_pmap_img[idx].row_bytes());            return true;        }        return false;    }    //------------------------------------------------------------------------    void platform_support::force_redraw()    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -