Exemplo n.º 1
0
        // snapshot/movie helpers

        //-------------------------------------------------
        //  create_snapshot_bitmap - creates a
        //  bitmap containing the screenshot for the
        //  given screen
        //-------------------------------------------------
        //typedef software_renderer<UINT32, 0,0,0, 16,8,0, false, true> snap_renderer_bilinear;
        //typedef software_renderer<UINT32, 0,0,0, 16,8,0, false, false> snap_renderer;

        void create_snapshot_bitmap(screen_device screen)
        {
            // select the appropriate view in our dummy target
            if (m_snap_native && screen != null)
            {
                screen_device_enumerator iter = new screen_device_enumerator(machine().root_device());
                int view_index = iter.indexof(screen);
                assert(view_index != -1);
                m_snap_target.set_view((unsigned)view_index);
            }

            // get the minimum width/height and set it on the target and bitmap
            s32 width;
            s32 height;

            compute_snapshot_size(out width, out height);
            m_snap_target.set_bounds(width, height);
            if (width != m_snap_bitmap.width() || height != m_snap_bitmap.height())
            {
                m_snap_bitmap.resize(width, height);
            }

            // render the screen there
            render_primitive_list primlist = m_snap_target.get_primitives();

            primlist.acquire_lock();
            if (machine().options().snap_bilinear())
            {
                //typedef software_renderer<u32, 0,0,0, 16,8,0, false, true> snap_renderer_bilinear;
                //snap_renderer_bilinear::draw_primitives(primlist, &m_snap_bitmap.pix(0), width, height, m_snap_bitmap.rowpixels());
                software_renderer <u32, int_const_0, int_const_0, int_const_0, int_const_16, int_const_8, int_const_0, bool_const_false, bool_const_true> .draw_primitives(primlist, m_snap_bitmap.pix(0), (u32)width, (u32)height, (u32)m_snap_bitmap.rowpixels());
            }
            else
            {
                //typedef software_renderer<u32, 0,0,0, 16,8,0, false, false> snap_renderer;
                //snap_renderer::draw_primitives(primlist, &m_snap_bitmap.pix(0), width, height, m_snap_bitmap.rowpixels());
                software_renderer <u32, int_const_0, int_const_0, int_const_0, int_const_16, int_const_8, int_const_0, bool_const_false, bool_const_false> .draw_primitives(primlist, m_snap_bitmap.pix(0), (u32)width, (u32)height, (u32)m_snap_bitmap.rowpixels());
            }
            primlist.release_lock();
        }
Exemplo n.º 2
0
        protected virtual uint32_t screen_update(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect)
        {
            //printf("%f %f\n", m_state.m_fragments[0].y, m_state.m_fragments[m_state.m_fragments.size()-1].y);
            bool  force_vector = screen.screen_type() == SCREEN_TYPE_VECTOR || (m_vector.op0.read() & 1) != 0;
            bool  debug_timing = (m_enable.op0.read() & 2) == 2;
            bool  test_pat     = (m_enable.op0.read() & 4) == 4;
            rgb_t backcol      = debug_timing ? new rgb_t(0xff, 0xff, 0x00, 0x00) : new rgb_t(0xff, 0x00, 0x00, 0x00);

            if (!force_vector)
            {
                screen.set_video_attributes(0);
                bitmap.fill(backcol);
                foreach (var f in m_state.m_fragments)
                {
                    if (f.y < bitmap.height())
                    {
                        bitmap.plot_box((int32_t)f.x, (int32_t)f.y, (int32_t)(f.xr - f.x), 1, f.col);
                    }
                }

                if (test_pat)
                {
                    draw_testpat(screen, bitmap, cliprect);
                }
            }
            else
            {
                screen.set_video_attributes(VIDEO_SELF_RENDER);

                uint32_t flags = PRIMFLAG_ANTIALIAS(1)
                                 | PRIMFLAG_BLENDMODE(BLENDMODE_ADD)
                                 | (screen.screen_type() == SCREEN_TYPE_VECTOR ? PRIMFLAG_VECTOR(1) : 0);
                rectangle visarea = screen.visible_area();
                float     xscale  = 1.0f / (float)visarea.width();
                float     yscale  = 1.0f / (float)visarea.height();
                float     xoffs   = (float)visarea.min_x;
                float     yoffs   = (float)visarea.min_y;
                screen.container().empty();
                screen.container().add_rect(0.0f, 0.0f, 1.0f, 1.0f, new rgb_t(0xff, 0x00, 0x00, 0x00),
                                            PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)
                                            | (screen.screen_type() == SCREEN_TYPE_VECTOR ? PRIMFLAG_VECTORBUF(1) : 0));

                float last_y = -1e6f;
                foreach (var f in m_state.m_fragments)
                {
                    float x0 = (f.x - xoffs) * xscale;
                    float y0 = (f.y - yoffs) * yscale;
                    float x1 = (f.xr - xoffs) * xscale;

                    rgb_t col = (debug_timing && f.y < last_y) ? backcol : new rgb_t(f.col);

                    // FIXME: Debug check for proper vsync timing
#if false
                    auto w = m_scanline_height * xscale * 0.5;
                    screen.container().add_line(
                        x0 + w, y0, x1 - w, y0, m_scanline_height * yscale,
                        nom_col(f.col),
//                          (0xff << 24) | (f.col & 0xffffff),
                        flags);
#elif true
                    float y1 = (f.y + m_scanline_height - yoffs) * yscale;
                    screen.container().add_rect(
                        x0, y0, x1, y1,
                        new rgb_t(nom_col(col)),
//                          (0xaf << 24) | (f.col & 0xffffff),
                        flags);
#else
                    const float y1((f.y + m_scanline_height - yoffs) *yscale);

                    // Crashes with bgfx
                    screen.container().add_quad(
                        x0, y0, x1, y1,
                        rgb_t(nom_col(f.col)),
//                          (0xaf << 24) | (f.col & 0xffffff),
                        m_texture,
                        flags);
#endif

                    last_y = f.y;
                }
            }

            m_state.m_fragments.clear();
            return(0);
        }