Ticket #14072: 20230130-ags-hob-barrow-debug-1.patch

File 20230130-ags-hob-barrow-debug-1.patch, 6.0 KB (added by digitall, 15 months ago)
  • engines/ags/engine/ac/draw.cpp

    diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
    index cf52ebf3c5b..4f628f2a2a8 100644
    a b static void dispose_debug_room_drawdata() {  
    423423}
    424424
    425425void dispose_room_drawdata() {
     426        debug(1, "%s", __FUNCTION__);
    426427        _GP(CameraDrawData).clear();
    427428        dispose_invalid_regions(true);
    428429}
    void on_mainviewport_changed() {  
    470471
    471472// Allocates a bitmap for rendering camera/viewport pair (software render mode)
    472473void prepare_roomview_frame(Viewport *view) {
     474        debug(1, "%s(view_index: %d)", __FUNCTION__, view->GetID());
    473475        if (!view->GetCamera()) return; // no camera link
    474476        const int view_index = view->GetID();
    475477        const Size view_sz = view->GetRect().GetSize();
    void prepare_roomview_frame(Viewport *view) {  
    482484        //   regions outside of master bitmap, and we must not clamp surface size to virtual screen because
    483485        //   plugins may want to also use viewport bitmap, therefore it should retain full size.
    484486        if (cam_sz == view_sz && !draw_dat.IsOffscreen) {
     487                debug(1, "#1");
    485488                // note we keep the buffer allocated in case it will become useful later
    486489                draw_dat.Frame.reset();
    487490        } else {
     491                debug(1, "#2");
     492                debug(1, " _GP(CameraDrawData)[view_index].Frame.get(): %p", (void *)(_GP(CameraDrawData)[view_index].Frame.get()));
    488493                PBitmap &camera_frame = draw_dat.Frame;
    489494                PBitmap &camera_buffer = draw_dat.Buffer;
    490495                if (!camera_buffer || camera_buffer->GetWidth() < cam_sz.Width || camera_buffer->GetHeight() < cam_sz.Height) {
     496                        debug(1, "#3");
    491497                        // Allocate new buffer bitmap with an extra size in case they will want to zoom out
    492498                        int room_width = data_to_game_coord(_GP(thisroom).Width);
    493499                        int room_height = data_to_game_coord(_GP(thisroom).Height);
     500                        debug(1, "room_width: %d room_height: %d", room_width, room_height);
    494501                        Size alloc_sz = Size::Clamp(cam_sz * 2, Size(1, 1), Size(room_width, room_height));
     502                        debug(1, "alloc_sz.Width: %d alloc_sz.Height: %d", alloc_sz.Width, alloc_sz.Height);
    495503                        camera_buffer.reset(new Bitmap(alloc_sz.Width, alloc_sz.Height, _G(gfxDriver)->GetMemoryBackBuffer()->GetColorDepth()));
    496504                }
    497505
    498506                if (!camera_frame || camera_frame->GetSize() != cam_sz) {
     507                        debug(1, "#4");
    499508                        camera_frame.reset(BitmapHelper::CreateSubBitmap(camera_buffer.get(), RectWH(cam_sz)));
    500509                }
     510                assert(draw_dat.Frame->GetAllegroBitmap()->_owner != nullptr);
     511                assert(draw_dat.Buffer->GetAllegroBitmap()->_owner != nullptr);
     512                debug(1, " _GP(CameraDrawData)[view_index].Frame.get(): %p", (void *)(_GP(CameraDrawData)[view_index].Frame.get()));
    501513        }
     514
     515        /*{
     516                RoomCameraDrawData &d = _GP(CameraDrawData)[view_index];
     517                assert(d.Frame->GetAllegroBitmap()->_owner != nullptr);
     518                assert(d.Buffer->GetAllegroBitmap()->_owner != nullptr);
     519        }*/
    502520}
    503521
    504522// Syncs room viewport and camera in case either size has changed
    void sync_roomview(Viewport *view) {  
    513531}
    514532
    515533void init_room_drawdata() {
     534        debug(1, "%s", __FUNCTION__);
    516535        // Update debug overlays, if any were on
    517536        debug_draw_room_mask(_G(debugRoomMask));
    518537        debug_draw_movelist(_G(debugMoveListChar));
    void init_room_drawdata() {  
    522541                return;
    523542        // Make sure all frame buffers are created for software drawing
    524543        int view_count = _GP(play).GetRoomViewportCount();
     544        debug(1, "view_count: %d", view_count);
    525545        _GP(CameraDrawData).resize(view_count);
    526546        for (int i = 0; i < _GP(play).GetRoomViewportCount(); ++i)
    527547                sync_roomview(_GP(play).GetRoomViewport(i).get());
    528548}
    529549
    530550void on_roomviewport_created(int index) {
     551        debug(1, "%s(%d)", __FUNCTION__, index);
    531552        if (!_G(gfxDriver) || _G(gfxDriver)->RequiresFullRedrawEachFrame())
    532553                return;
    533554        if ((size_t)index < _GP(CameraDrawData).size())
    void on_roomviewport_created(int index) {  
    536557}
    537558
    538559void on_roomviewport_deleted(int index) {
     560        debug(1, "%s(%d)", __FUNCTION__, index);
    539561        if (_G(gfxDriver)->RequiresFullRedrawEachFrame())
    540562                return;
    541563        _GP(CameraDrawData).erase(_GP(CameraDrawData).begin() + index);
    void on_roomviewport_deleted(int index) {  
    543565}
    544566
    545567void on_roomviewport_changed(Viewport *view) {
     568        debug(1, "%s", __FUNCTION__);
    546569        if (_G(gfxDriver)->RequiresFullRedrawEachFrame())
    547570                return;
    548571        if (!view->IsVisible() || view->GetCamera() == nullptr)
    PBitmap draw_room_background(Viewport *view) {  
    17891812        // If separate bitmap was prepared for this view/camera pair then use it, draw untransformed
    17901813        // and blit transformed whole surface later.
    17911814        const bool draw_to_camsurf = _GP(CameraDrawData)[view_index].Frame != nullptr;
     1815        debug(1, "draw_to_camsurf: %d view_index:%d _GP(CameraDrawData)[view_index].Frame.get():%p", draw_to_camsurf, view_index, (void *)(_GP(CameraDrawData)[view_index].Frame.get()));
    17921816        Bitmap *roomcam_surface = draw_to_camsurf ? _GP(CameraDrawData)[view_index].Frame.get() : ds;
     1817        assert(roomcam_surface->GetAllegroBitmap()->_owner != nullptr);
    17931818        {
    17941819                // For software renderer: copy dirty rects onto the virtual screen.
    17951820                // TODO: that would be SUPER NICE to reorganize the code and move this operation into SoftwareGraphicDriver somehow.
  • engines/ags/lib/allegro/surface.cpp

    diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
    index d4de07dd46c..a4676910779 100644
    a b void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,  
    111111                  int dstX, int dstY, bool horizFlip, bool vertFlip,
    112112                  bool skipTrans, int srcAlpha, int tintRed, int tintGreen,
    113113                  int tintBlue) {
     114        assert(_owner != nullptr);
    114115        assert(format.bytesPerPixel == 2 || format.bytesPerPixel == 4 ||
    115116               (format.bytesPerPixel == 1 && srcBitmap->format.bytesPerPixel == 1));
    116117
  • engines/ags/lib/allegro/surface.h

    diff --git a/engines/ags/lib/allegro/surface.h b/engines/ags/lib/allegro/surface.h
    index 6ac73b40a5c..acd5b5f8ac4 100644
    a b  
    2929namespace AGS3 {
    3030
    3131class BITMAP {
    32 private:
     32public:
    3333        Graphics::ManagedSurface *_owner;
    34         public:
    3534        int16 &w, &h, &pitch;
    3635        Graphics::PixelFormat &format;
    3736        bool clip;