[Scummvm-git-logs] scummvm master -> 7cbdb7dcbfb6a626d82cd69dd0dfbcb01e164c87

sev- noreply at scummvm.org
Fri Sep 6 11:26:33 UTC 2024


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d13cfdb4d3 QDENGINE: DT: Display QDA tiles
7cbdb7dcbf QDENGINE: Avoid clipping in tilemap rendering


Commit: d13cfdb4d3ef71ea462510e9e585dc2055bfd0ab
    https://github.com/scummvm/scummvm/commit/d13cfdb4d3ef71ea462510e9e585dc2055bfd0ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-06T13:26:18+02:00

Commit Message:
QDENGINE: DT: Display QDA tiles

Changed paths:
    engines/qdengine/debugger/debugtools.cpp
    engines/qdengine/system/graphics/gr_tile_animation.cpp
    engines/qdengine/system/graphics/gr_tile_animation.h


diff --git a/engines/qdengine/debugger/debugtools.cpp b/engines/qdengine/debugger/debugtools.cpp
index 08d49e980d1..a805d5f313e 100644
--- a/engines/qdengine/debugger/debugtools.cpp
+++ b/engines/qdengine/debugger/debugtools.cpp
@@ -44,6 +44,8 @@
 
 namespace QDEngine {
 
+const int TILES_ID = -10;
+
 ImGuiState *_state = nullptr;
 
 static GLuint loadTextureFromSurface(Graphics::Surface *surface) {
@@ -81,34 +83,47 @@ ImGuiImage getImageID(Common::Path filename, int frameNum) {
 	_state->_qdaToDisplayFrameCount = animation->num_frames();
 
 	int sx = 10, sy = 10;
+	Graphics::ManagedSurface *surface = nullptr;
 
-	if (animation->tileAnimation() && 0) {
-		Vect2i size = animation->tileAnimation()->frameSize();
+	if (frameNum != TILES_ID) {
+		if (animation->tileAnimation() && 0) {
+			Vect2i size = animation->tileAnimation()->frameSize();
 
-		sx = size.x;
-		sy = size.y;
-	} else {
-		qdAnimationFrame *frame = animation->get_frame(frameNum);
+			sx = size.x;
+			sy = size.y;
+		} else {
+			qdAnimationFrame *frame = animation->get_frame(frameNum);
 
-		sx = frame->size_x();
-		sy = frame->size_y();
-	}
+			sx = frame->size_x();
+			sy = frame->size_y();
+		}
 
-	Graphics::ManagedSurface surface(sx, sy, g_engine->_pixelformat);
+		surface = new Graphics::ManagedSurface(sx, sy, g_engine->_pixelformat);
 
-	animation->set_cur_frame(frameNum);
+		animation->set_cur_frame(frameNum);
 
-	grDispatcher::instance()->surfaceOverride(&surface);
-	animation->redraw(sx / 2, sy/ 2, 0, 0);
-	grDispatcher::instance()->resetSurfaceOverride();
+		grDispatcher::instance()->surfaceOverride(surface);
+		animation->redraw(sx / 2, sy/ 2, 0, 0);
+		grDispatcher::instance()->resetSurfaceOverride();
+	} else {
+		if (animation->tileAnimation()) {
+			surface = animation->tileAnimation()->dumpTiles(25);
 
-	_state->_frames[key] = { (ImTextureID)(intptr_t)loadTextureFromSurface(surface.surfacePtr()), sx, sy };
+			sx = surface->w;
+			sy = surface->h;
+		}
+	}
+
+	if (surface)
+		_state->_frames[key] = { (ImTextureID)(intptr_t)loadTextureFromSurface(surface->surfacePtr()), sx, sy };
+
+	delete surface;
 
 	return _state->_frames[key];
 }
 
-void showImage(const ImGuiImage &image, const char *name, float thumbnailSize) {
-	ImVec2 size = { (float)image.width * 2, (float)image.height * 2 };
+void showImage(const ImGuiImage &image, const char *name, float scale) {
+	ImVec2 size = { (float)image.width * scale, (float)image.height * scale };
 
 	ImGui::BeginGroup();
 	ImVec2 screenPos = ImGui::GetCursorScreenPos();
@@ -194,40 +209,63 @@ void showArchives() {
 				ImGui::Text("Frame <none>");
 			}
 
-			ImGui::Button("\ue020"); // Fast Rewind    // fast_rewind
+			ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
+            if (ImGui::BeginTabBar("FrameTabBar", tab_bar_flags)) {
 
-			ImGui::SameLine();
-			if (ImGui::Button("\ue045")) { // Skip Previous    // skip_previous
-				_state->_qdaToDisplayFrame = _state->_qdaToDisplayFrame + totalFrames - 1;
-				_state->_qdaToDisplayFrame %= totalFrames;
-			}
-			ImGui::SameLine();
-			if (ImGui::Button("\ue037")) // Play    // play_arrow
-				_state->_qdaIsPlaying = !_state->_qdaIsPlaying;
-
-			ImGui::SameLine();
-			if (ImGui::Button("\ue044")) { // Skip Next    // skip_next
-				_state->_qdaToDisplayFrame += 1;
-				_state->_qdaToDisplayFrame %= totalFrames;
-			}
-			ImGui::SameLine();
-			ImGui::Button("\ue01f"); // Fast Forward    // fast_forward
-			ImGui::SameLine();
+				if (ImGui::BeginTabItem("Animation")) {
+
+					ImGui::Button("\ue020"); // Fast Rewind    // fast_rewind
+
+					ImGui::SameLine();
+					if (ImGui::Button("\ue045")) { // Skip Previous    // skip_previous
+						_state->_qdaToDisplayFrame = _state->_qdaToDisplayFrame + totalFrames - 1;
+						_state->_qdaToDisplayFrame %= totalFrames;
+					}
+					ImGui::SameLine();
+					if (ImGui::Button("\ue037")) // Play    // play_arrow
+						_state->_qdaIsPlaying = !_state->_qdaIsPlaying;
+
+					ImGui::SameLine();
+					if (ImGui::Button("\ue044")) { // Skip Next    // skip_next
+						_state->_qdaToDisplayFrame += 1;
+						_state->_qdaToDisplayFrame %= totalFrames;
+					}
+					ImGui::SameLine();
+					ImGui::Button("\ue01f"); // Fast Forward    // fast_forward
+					ImGui::SameLine();
 
-			// Frame Count
-			char buf[6];
-			snprintf(buf, 6, "%d", _state->_qdaToDisplayFrame);
+					// Frame Count
+					char buf[6];
+					snprintf(buf, 6, "%d", _state->_qdaToDisplayFrame);
 
-			ImGui::SetNextItemWidth(35);
-			ImGui::InputText("##frame", buf, 5, ImGuiInputTextFlags_CharsDecimal);
-			ImGui::SetItemTooltip("Frame");
+					ImGui::SetNextItemWidth(35);
+					ImGui::InputText("##frame", buf, 5, ImGuiInputTextFlags_CharsDecimal);
+					ImGui::SetItemTooltip("Frame");
 
-			ImGui::Separator();
+					ImGui::Separator();
 
-			if (!_state->_qdaToDisplay.empty()) {
-				showImage(imgID, (char *)transCyrillic(_state->_qdaToDisplay.toString()), 120.0f);
-			} else {
-				ImGui::InvisibleButton("##canvas", ImVec2(32.f, 32.f));
+					if (!_state->_qdaToDisplay.empty()) {
+						showImage(imgID, (char *)transCyrillic(_state->_qdaToDisplay.toString()), 2.0);
+					} else {
+						ImGui::InvisibleButton("##canvas", ImVec2(32.f, 32.f));
+					}
+
+					ImGui::EndTabItem();
+				}
+
+				if (ImGui::BeginTabItem("Tiles")) {
+					if (!_state->_qdaToDisplay.empty()) {
+						imgID = getImageID(_state->_qdaToDisplay, TILES_ID);
+
+						showImage(imgID, (char *)transCyrillic(_state->_qdaToDisplay.toString()), 1.0);
+					} else {
+						ImGui::InvisibleButton("##canvas", ImVec2(32.f, 32.f));
+					}
+
+					ImGui::EndTabItem();
+				}
+
+				ImGui::EndTabBar();
 			}
 
 			ImGui::EndChild();
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index c89729367b3..476d0689006 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -475,9 +475,7 @@ bool grTileAnimation::wasFrameSizeChanged(int frame_index, int scaleIdx, float s
 	return true;
 }
 
-void grTileAnimation::dumpTiles(Common::Path basename, int tilesPerRow) {
-	Common::Path path = Common::Path(Common::String::format("dumps/%s.tiles.png", transCyrillic(basename.baseName())));
-
+Graphics::ManagedSurface *grTileAnimation::dumpTiles(int tilesPerRow) const {
 	int w = tilesPerRow;
 	int h = (_tileOffsets.size() + tilesPerRow - 1) / tilesPerRow;
 
@@ -503,6 +501,14 @@ void grTileAnimation::dumpTiles(Common::Path basename, int tilesPerRow) {
 		y += GR_TILE_SPRITE_SIZE_X + 1;
 	}
 
+	return dstSurf;
+}
+
+void grTileAnimation::dumpTiles(Common::Path basename, int tilesPerRow) const {
+	Common::Path path = Common::Path(Common::String::format("dumps/%s.tiles.png", transCyrillic(basename.baseName())));
+
+	Graphics::ManagedSurface *dstSurf = dumpTiles(tilesPerRow);
+
 	Common::DumpFile bitmapFile;
 	bitmapFile.open(path, true);
 	Image::writePNG(bitmapFile, *(dstSurf->surfacePtr()));
@@ -513,5 +519,4 @@ void grTileAnimation::dumpTiles(Common::Path basename, int tilesPerRow) {
 	delete dstSurf;
 }
 
-
 } // namespace QDEngine
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 2af342d8b3f..31736cd8edc 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -32,6 +32,10 @@ namespace Common {
 class SeekableReadStream;
 }
 
+namespace Graphics {
+class ManagedSurface;
+}
+
 namespace QDEngine {
 
 typedef void (*CompressionProgressHandler)(int percents_loaded, void *context);
@@ -85,7 +89,8 @@ public:
 	int find_closest_scale(float *scale) const;
 	bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const;
 
-	void dumpTiles(Common::Path baseName, int tilesPerRow);
+	Graphics::ManagedSurface *dumpTiles(int tilesPerRow) const;
+	void dumpTiles(Common::Path baseName, int tilesPerRow) const;
 
 private:
 


Commit: 7cbdb7dcbfb6a626d82cd69dd0dfbcb01e164c87
    https://github.com/scummvm/scummvm/commit/7cbdb7dcbfb6a626d82cd69dd0dfbcb01e164c87
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-06T13:26:18+02:00

Commit Message:
QDENGINE: Avoid clipping in tilemap rendering

Changed paths:
    engines/qdengine/system/graphics/gr_dispatcher.h
    engines/qdengine/system/graphics/gr_tile_animation.cpp
    engines/qdengine/system/graphics/gr_tile_sprite.cpp


diff --git a/engines/qdengine/system/graphics/gr_dispatcher.h b/engines/qdengine/system/graphics/gr_dispatcher.h
index 2aa54caa4a0..fdf055c0043 100644
--- a/engines/qdengine/system/graphics/gr_dispatcher.h
+++ b/engines/qdengine/system/graphics/gr_dispatcher.h
@@ -203,7 +203,7 @@ public:
 	void putSprMask_a(int x, int y, int sx, int sy, const byte *p, uint32 mask_color, int mask_alpha, int mode);
 	void putSprMask_a(int x, int y, int sx, int sy, const byte *p, uint32 mask_color, int mask_alpha, int mode, float scale);
 
-	void putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode, Graphics::ManagedSurface *surface = nullptr);
+	void putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode, Graphics::ManagedSurface *surface = nullptr, bool clip = true);
 
 	void putChar(int x, int y, uint32 color, int font_sx, int font_sy, const byte *font_alpha, const grScreenRegion &char_region);
 
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 476d0689006..dfdf0ab9b29 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -138,7 +138,7 @@ grTileSprite grTileAnimation::getTile(int tile_index) const {
 			break;
 		}
 		if (!grTileSprite::uncompress(&*_tileData.begin() + _tileOffsets[tile_index], GR_TILE_SPRITE_SIZE, tile_buf, _compression)) {
-			assert(0 && "Unknown compression algorithm");
+			warning("Unknown compression algorithm");
 		}
 	}
 
@@ -484,11 +484,11 @@ Graphics::ManagedSurface *grTileAnimation::dumpTiles(int tilesPerRow) const {
 	int index = 0;
 
 	int x = 0, y = 0;
-	for (int32 i = 0; i < tilesPerRow; i++) {
+	for (int32 i = 0; i < h; i++) {
 		x = 0;
 
-		for (int32 j = 0; j < tilesPerRow; j++) {
-			grDispatcher::instance()->putTileSpr(x, y, getTile(index++), _hasAlpha, 0, dstSurf);
+		for (int32 j = 0; j < w; j++) {
+			grDispatcher::instance()->putTileSpr(x, y, getTile(index++), _hasAlpha, 0, dstSurf, false);
 			x += GR_TILE_SPRITE_SIZE_X + 1;
 
 			if (index >= _tileOffsets.size())
diff --git a/engines/qdengine/system/graphics/gr_tile_sprite.cpp b/engines/qdengine/system/graphics/gr_tile_sprite.cpp
index 64f32745895..f629a7b7bd8 100644
--- a/engines/qdengine/system/graphics/gr_tile_sprite.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_sprite.cpp
@@ -96,14 +96,16 @@ bool decodeRLE(const uint32 *in_data, uint32 *out_data) {
 
 } // namespace tile_compress
 
-void grDispatcher::putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode, Graphics::ManagedSurface *surf) {
+void grDispatcher::putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode, Graphics::ManagedSurface *surf, bool clip) {
 	int px = 0;
 	int py = 0;
 
 	int psx = GR_TILE_SPRITE_SIZE_X;
 	int psy = GR_TILE_SPRITE_SIZE_Y;
 
-	if (!clip_rectangle(x, y, px, py, psx, psy)) return;
+	if (clip && !clip_rectangle(x, y, px, py, psx, psy))
+		return;
+
 	int dx = -1;
 	int dy = -1;
 




More information about the Scummvm-git-logs mailing list