diff --git a/ion/src/simulator/assets/horizontal_arrow.jpg b/ion/src/simulator/assets/horizontal_arrow.jpg deleted file mode 100644 index 248143985..000000000 Binary files a/ion/src/simulator/assets/horizontal_arrow.jpg and /dev/null differ diff --git a/ion/src/simulator/assets/horizontal_arrow.png b/ion/src/simulator/assets/horizontal_arrow.png new file mode 100644 index 000000000..37c38df24 Binary files /dev/null and b/ion/src/simulator/assets/horizontal_arrow.png differ diff --git a/ion/src/simulator/assets/large_squircle.jpg b/ion/src/simulator/assets/large_squircle.jpg deleted file mode 100644 index cb729b6b9..000000000 Binary files a/ion/src/simulator/assets/large_squircle.jpg and /dev/null differ diff --git a/ion/src/simulator/assets/large_squircle.png b/ion/src/simulator/assets/large_squircle.png new file mode 100644 index 000000000..b83f4e223 Binary files /dev/null and b/ion/src/simulator/assets/large_squircle.png differ diff --git a/ion/src/simulator/assets/round.jpg b/ion/src/simulator/assets/round.jpg deleted file mode 100644 index 9311aacee..000000000 Binary files a/ion/src/simulator/assets/round.jpg and /dev/null differ diff --git a/ion/src/simulator/assets/round.png b/ion/src/simulator/assets/round.png new file mode 100644 index 000000000..2085d125d Binary files /dev/null and b/ion/src/simulator/assets/round.png differ diff --git a/ion/src/simulator/assets/small_squircle.jpg b/ion/src/simulator/assets/small_squircle.jpg deleted file mode 100644 index 9673e9851..000000000 Binary files a/ion/src/simulator/assets/small_squircle.jpg and /dev/null differ diff --git a/ion/src/simulator/assets/small_squircle.png b/ion/src/simulator/assets/small_squircle.png new file mode 100644 index 000000000..9e7583a4f Binary files /dev/null and b/ion/src/simulator/assets/small_squircle.png differ diff --git a/ion/src/simulator/assets/vertical_arrow.jpg b/ion/src/simulator/assets/vertical_arrow.jpg deleted file mode 100644 index b6e34cf1d..000000000 Binary files a/ion/src/simulator/assets/vertical_arrow.jpg and /dev/null differ diff --git a/ion/src/simulator/assets/vertical_arrow.png b/ion/src/simulator/assets/vertical_arrow.png new file mode 100644 index 000000000..05672b9a5 Binary files /dev/null and b/ion/src/simulator/assets/vertical_arrow.png differ diff --git a/ion/src/simulator/macos/images.m b/ion/src/simulator/macos/images.m index 57f839e3e..03c82ab51 100644 --- a/ion/src/simulator/macos/images.m +++ b/ion/src/simulator/macos/images.m @@ -3,7 +3,7 @@ #include #include -SDL_Texture * IonSimulatorLoadImage(SDL_Renderer * renderer, const char * identifier, bool withTransparency, uint8_t alpha) { +SDL_Texture * IonSimulatorLoadImage(SDL_Renderer * renderer, const char * identifier) { NSImage * nsImage = [NSImage imageNamed:[NSString stringWithUTF8String:identifier]]; CGImageRef cgImage = [nsImage CGImageForProposedRect:NULL context:NULL @@ -15,11 +15,12 @@ SDL_Texture * IonSimulatorLoadImage(SDL_Renderer * renderer, const char * identi size_t height = CGImageGetHeight(cgImage); size_t bytesPerPixel = 4; - size_t bitsPerPixel = bytesPerPixel*8; size_t bytesPerRow = bytesPerPixel * width; size_t bitsPerComponent = 8; - void * bitmapData = malloc(height * width * bytesPerPixel); + size_t size = height * width * bytesPerPixel; + void * bitmapData = malloc(size); + memset(bitmapData, 0, size); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate( @@ -33,21 +34,24 @@ SDL_Texture * IonSimulatorLoadImage(SDL_Renderer * renderer, const char * identi CGContextRelease(context); CGColorSpaceRelease(colorSpace); - SDL_Surface * surface = SDL_CreateRGBSurfaceWithFormatFrom( - bitmapData, - width, - height, - bitsPerPixel, - bytesPerRow, - SDL_PIXELFORMAT_ABGR8888); + SDL_Texture * texture = SDL_CreateTexture( + renderer, + SDL_PIXELFORMAT_ABGR8888, + SDL_TEXTUREACCESS_STATIC, + width, + height + ); - SDL_SetColorKey(surface, withTransparency, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF)); - SDL_SetSurfaceAlphaMod(surface, alpha); + SDL_UpdateTexture( + texture, + NULL, + bitmapData, + bytesPerPixel * width + ); - SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface); + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); free(bitmapData); - SDL_FreeSurface(surface); return texture; } diff --git a/ion/src/simulator/shared/apple/helpers.mak b/ion/src/simulator/shared/apple/helpers.mak index eaec0ac4e..53442cd27 100644 --- a/ion/src/simulator/shared/apple/helpers.mak +++ b/ion/src/simulator/shared/apple/helpers.mak @@ -16,15 +16,15 @@ $(simulator_app_binary): $(foreach arch,$(ARCHS),$(BUILD_DIR)/$(arch)/%.bin) | $ # Background & Keys images -define rule_for_jpg_asset -simulator_app_deps += $(call simulator_app_resource,$(1).jpg) -$(call simulator_app_resource,$(1).jpg): ion/src/simulator/assets/$(1).jpg | $$$$(@D)/. +define rule_for_asset +simulator_app_deps += $(call simulator_app_resource,$(1)) +$(call simulator_app_resource,$(1)): ion/src/simulator/assets/$(1) | $$$$(@D)/. $(call rule_label,COPY) $(Q) cp $$^ $$@ endef -JPG_ASSETS = background horizontal_arrow large_squircle round small_squircle vertical_arrow -$(foreach ASSET,$(JPG_ASSETS),$(eval $(call rule_for_jpg_asset,$(ASSET)))) +ASSETS = background.jpg horizontal_arrow.png large_squircle.png round.png small_squircle.png vertical_arrow.png +$(foreach ASSET,$(ASSETS),$(eval $(call rule_for_asset,$(ASSET)))) # Process icons @@ -45,4 +45,4 @@ $(addprefix $(SIMULATOR_ICONSET)/,icon_%.png): ion/src/simulator/assets/logo.svg # Export simulator app dependencies simulator_app_deps += $(simulator_app_binary) -simulator_app_deps += $(call simulator_app_plist,Info.plist) \ No newline at end of file +simulator_app_deps += $(call simulator_app_plist,Info.plist) diff --git a/ion/src/simulator/shared/layout.cpp b/ion/src/simulator/shared/layout.cpp index 890ce13a6..a41c39e82 100644 --- a/ion/src/simulator/shared/layout.cpp +++ b/ion/src/simulator/shared/layout.cpp @@ -103,11 +103,11 @@ public: }; static constexpr size_t NumberOfShapes = (size_t)Shape::NumberOfShapes; static constexpr const char * imagePathForKey[KeyLayout::NumberOfShapes] = { - "horizontal_arrow.jpg", - "vertical_arrow.jpg", - "round.jpg", - "small_squircle.jpg", - "large_squircle.jpg" + "horizontal_arrow.png", + "vertical_arrow.png", + "round.png", + "small_squircle.png", + "large_squircle.png" }; constexpr KeyLayout(float x, float y, Shape shape) : @@ -198,14 +198,13 @@ static void getKeyRectangle(int validKeyIndex, SDL_Texture * texture, SDL_Rect * makeAbsolute(fRect, rect); } -static constexpr uint8_t k_blendingRatio = 0x44; static SDL_Texture * sBackgroundTexture = nullptr; static SDL_Texture * sKeyLayoutTextures[KeyLayout::NumberOfShapes]; void init(SDL_Renderer * renderer) { - sBackgroundTexture = IonSimulatorLoadImage(renderer, "background.jpg", false, 0xFF); + sBackgroundTexture = IonSimulatorLoadImage(renderer, "background.jpg"); for (size_t i = 0; i < KeyLayout::NumberOfShapes; i++) { - sKeyLayoutTextures[i] = IonSimulatorLoadImage(renderer, KeyLayout::imagePathForKey[i], true, k_blendingRatio); + sKeyLayoutTextures[i] = IonSimulatorLoadImage(renderer, KeyLayout::imagePathForKey[i]); } } diff --git a/ion/src/simulator/shared/platform.h b/ion/src/simulator/shared/platform.h index ce566a4a9..494c83c23 100644 --- a/ion/src/simulator/shared/platform.h +++ b/ion/src/simulator/shared/platform.h @@ -11,7 +11,7 @@ extern "C" { /* Those functions should be implemented per-platform. * They are defined as C function for easier interop. */ -SDL_Texture * IonSimulatorLoadImage(SDL_Renderer * renderer, const char * identifier, bool withTransparency, uint8_t alpha); +SDL_Texture * IonSimulatorLoadImage(SDL_Renderer * renderer, const char * identifier); char * IonSimulatorGetLanguageCode(); #if EPSILON_SDL_SCREEN_ONLY