Android.mk
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 7501 b27825bb5879
child 7659 ac4ce59c40e7
permissions -rwxr-xr-x
Fixed bug 1968 - SDL_RenderCopy stretch loses proportion on viewport boundaries for 3D renderers

driedfruit

SDL_RenderCopy clips dstrect against the viewport. Then it adjusts the
srcrect by "appropriate" amount of pixels. This amount is actually
wrong, quite a lot, because of the rounding errors introduced in the "*
factor / factor" scale.

real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;

For example:

I have a 32 x 32 srcrect and a 64 x 64 dstrect. So far the
stretching is done perfectly, by a factor of 2.

Now, consider dstrect being clipped against the viewport, so it becomes
56 x 64. Now, the factor becomes 1.75 ! The adjustment to "srcrect"
can't handle this, cause srcrect is in integers.

And thus we now have incorrect mapping, with dstrect not being in the
right proportion to srcrect.

The problem is most evident when upscaling stuff, like displaying a 8x8
texture with a zoom of 64 or more, and moving it beyond the corners of
the screen. It *looks* really really bad.

Note: RenderCopyEX does no such clipping, and is right to do so. The fix would be to remove any such clipping from RenderCopy too. And then fix the software renderer, because it has the same fault, independently of RenderCopy.

[attached patch]
this leaves Software Renderer buggy, as it does it's own clipping later on
slouken@4964
     1
LOCAL_PATH := $(call my-dir)
slouken@4964
     2
slouken@4964
     3
###########################
slouken@4964
     4
#
slouken@4964
     5
# SDL shared library
slouken@4964
     6
#
slouken@4964
     7
###########################
slouken@4964
     8
slouken@4964
     9
include $(CLEAR_VARS)
slouken@4964
    10
slouken@6270
    11
LOCAL_MODULE := SDL2
slouken@4964
    12
slouken@4964
    13
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
slouken@4964
    14
slouken@7311
    15
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
slouken@7311
    16
slouken@5090
    17
LOCAL_SRC_FILES := \
slouken@4964
    18
	$(subst $(LOCAL_PATH)/,, \
slouken@4964
    19
	$(wildcard $(LOCAL_PATH)/src/*.c) \
slouken@4964
    20
	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
slouken@5090
    21
	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
slouken@5090
    22
	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
slouken@5003
    23
	$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
slouken@5003
    24
	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
ewing@7501
    25
	$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
slouken@4964
    26
	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
slouken@4964
    27
	$(wildcard $(LOCAL_PATH)/src/events/*.c) \
slouken@4964
    28
	$(wildcard $(LOCAL_PATH)/src/file/*.c) \
slouken@5090
    29
	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
slouken@5090
    30
	$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
slouken@4964
    31
	$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
slouken@5090
    32
	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
slouken@5092
    33
	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
slouken@5090
    34
	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
slouken@6448
    35
	$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
slouken@5161
    36
	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
slouken@5204
    37
	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
slouken@4964
    38
	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
slouken@4964
    39
	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
slouken@5090
    40
	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
slouken@4964
    41
	$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
slouken@5090
    42
	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
slouken@4964
    43
	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
slouken@5092
    44
	$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
slouken@4964
    45
slouken@6208
    46
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
slouken@5204
    47
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
slouken@4964
    48
slouken@4964
    49
include $(BUILD_SHARED_LIBRARY)