Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a5343a7

Browse files
committed
[Bug 13227] Map the size of the native player layer correctly
1 parent ab87d63 commit a5343a7

File tree

6 files changed

+57
-8
lines changed

6 files changed

+57
-8
lines changed

engine/src/mac-av-player.mm

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static CVReturn MyDisplayLinkCallback (CVDisplayLinkRef displayLink,
128128
uint32_t m_selection_start, m_selection_finish;
129129
uint32_t m_selection_duration;
130130
uint32_t m_buffered_time;
131+
double m_scale;
131132
CMTimeScale m_time_scale;
132133

133134
bool m_play_selection_only : 1;
@@ -287,6 +288,8 @@ - (void)setPlayer:(AVPlayer *)player
287288
m_selection_start = 0;
288289
m_selection_finish = 0;
289290
m_buffered_time = 0;
291+
292+
m_scale = 1.0;
290293

291294
m_time_observer_token = nil;
292295
m_endtime_observer_token = nil;
@@ -834,9 +837,16 @@ - (void)setPlayer:(AVPlayer *)player
834837
MCMacPlatformWindow *t_window;
835838
t_window = (MCMacPlatformWindow *)m_window;
836839

840+
// PM-2015-11-26: [[ Bug 13277 ]] Scale m_rect before mapping
841+
MCRectangle t_rect = m_rect;
842+
t_rect.x *= m_scale;
843+
t_rect.y *= m_scale;
844+
t_rect.width *= m_scale;
845+
t_rect.height *= m_scale;
846+
837847
NSRect t_frame;
838-
t_window -> MapMCRectangleToNSRect(m_rect, t_frame);
839-
848+
t_window -> MapMCRectangleToNSRect(t_rect, t_frame);
849+
840850
m_synchronizing = true;
841851

842852
[m_view setFrame: t_frame];
@@ -1053,6 +1063,10 @@ - (void)setPlayer:(AVPlayer *)player
10531063
case kMCPlatformPlayerPropertyOffscreen:
10541064
Switch(*(bool *)p_value);
10551065
break;
1066+
case kMCPlatformPlayerPropertyScalefactor:
1067+
m_scale = *(double *)p_value;
1068+
Synchronize();
1069+
break;
10561070
case kMCPlatformPlayerPropertyRect:
10571071
m_rect = *(MCRectangle *)p_value;
10581072
Synchronize();
@@ -1249,6 +1263,10 @@ static Boolean AVAssetHasType(AVAsset *p_asset, NSString *p_type)
12491263
case kMCPlatformPlayerPropertyMirrored:
12501264
*(bool *)r_value = m_mirrored;
12511265
break;
1266+
1267+
case kMCPlatformPlayerPropertyScalefactor:
1268+
*(double *)r_value = m_scale;
1269+
break;
12521270
}
12531271
}
12541272

engine/src/mac-qt-player.mm

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ - (NSView *) newHitTest: (NSPoint) aPoint;
120120
uint32_t *m_markers;
121121
uindex_t m_marker_count;
122122
uint32_t m_last_marker;
123+
double m_scale;
123124

124125
MCRectangle m_rect;
125126
bool m_visible : 1;
@@ -250,6 +251,7 @@ inline NSComparisonResult do_QTTimeCompare (QTTime time, QTTime otherTime)
250251
m_last_current_time = do_QTMakeTime(INT64_MAX, 1);
251252
m_buffered_time = do_QTMakeTime(0, 1);
252253
m_mirrored = false;
254+
m_scale = 1.0;
253255
}
254256

255257
MCQTKitPlayer::~MCQTKitPlayer(void)
@@ -609,9 +611,16 @@ inline NSComparisonResult do_QTTimeCompare (QTTime time, QTTime otherTime)
609611
MCMacPlatformWindow *t_window;
610612
t_window = (MCMacPlatformWindow *)m_window;
611613

614+
// PM-2015-11-26: [[ Bug 13277 ]] Scale m_rect before mapping
615+
MCRectangle t_rect = m_rect;
616+
t_rect.x *= m_scale;
617+
t_rect.y *= m_scale;
618+
t_rect.width *= m_scale;
619+
t_rect.height *= m_scale;
620+
612621
NSRect t_frame;
613-
t_window -> MapMCRectangleToNSRect(m_rect, t_frame);
614-
622+
t_window -> MapMCRectangleToNSRect(t_rect, t_frame);
623+
615624
m_synchronizing = true;
616625

617626
[m_view setFrame: t_frame];
@@ -732,6 +741,10 @@ inline NSComparisonResult do_QTTimeCompare (QTTime time, QTTime otherTime)
732741
case kMCPlatformPlayerPropertyOffscreen:
733742
Switch(*(bool *)p_value);
734743
break;
744+
case kMCPlatformPlayerPropertyScalefactor:
745+
m_scale = *(double *)p_value;
746+
Synchronize();
747+
break;
735748
case kMCPlatformPlayerPropertyRect:
736749
m_rect = *(MCRectangle *)p_value;
737750
Synchronize();
@@ -946,6 +959,10 @@ static Boolean QTMovieHasType(Movie tmovie, OSType movtype)
946959
case kMCPlatformPlayerPropertyMirrored:
947960
*(bool *)r_value = m_mirrored;
948961
break;
962+
963+
case kMCPlatformPlayerPropertyScalefactor:
964+
*(double *)r_value = m_scale;
965+
break;
949966
}
950967
}
951968

engine/src/platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ enum MCPlatformPlayerProperty
989989

990990
kMCPlatformPlayerPropertyLoop,
991991
kMCPlatformPlayerPropertyMirrored,
992+
kMCPlatformPlayerPropertyScalefactor,
992993

993994
kMCPlatformPlayerPropertyQTVRNode,
994995
kMCPlatformPlayerPropertyQTVRPan,

engine/src/player-platform.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ Boolean MCPlayer::doubleup(uint2 which)
11351135
return True;
11361136
}
11371137

1138+
11381139
void MCPlayer::setrect(const MCRectangle &nrect)
11391140
{
11401141
rect = nrect;
@@ -1858,9 +1859,6 @@ void MCPlayer::syncbuffering(MCContext *p_dc)
18581859
// MW-2014-04-24: [[ Bug 12249 ]] If we are not in browse mode for this object, then it should be buffered.
18591860
t_should_buffer = t_should_buffer || getstack() -> gettool(this) != T_BROWSE;
18601861

1861-
// PM-2015-11-26: [[ Bug 13277 ]] If the scalefactor is not 1, then the player should be buffered.
1862-
t_should_buffer = t_should_buffer || getstack() -> view_get_content_scale() != 1.0;
1863-
18641862
if (m_platform_player != nil)
18651863
MCPlatformSetPlayerProperty(m_platform_player, kMCPlatformPlayerPropertyOffscreen, kMCPlatformPropertyTypeBool, &t_should_buffer);
18661864
}
@@ -2117,6 +2115,15 @@ void MCPlayer::showcontroller(Boolean show)
21172115
}
21182116
}
21192117

2118+
void MCPlayer::scale_native_rect(void)
2119+
{
2120+
if (m_platform_player != nil)
2121+
{
2122+
double t_scale_factor = getstack() -> view_get_content_scale();
2123+
MCPlatformSetPlayerProperty(m_platform_player, kMCPlatformPlayerPropertyScalefactor, kMCPlatformPropertyTypeDouble, &t_scale_factor);
2124+
}
2125+
}
2126+
21202127
Boolean MCPlayer::prepare(const char *options)
21212128
{
21222129
// For osversion < 10.8 we have to have QT initialized.

engine/src/player-platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MCPlayer : public MCControl
173173
Boolean setenabledtracks(const MCString &s);
174174
void getnodes(MCExecPoint &ep);
175175
void gethotspots(MCExecPoint &ep);
176-
176+
177177
// MW-2011-09-23: Ensures the buffering state is consistent with current flags
178178
// and such.
179179
void syncbuffering(MCContext *dc);
@@ -190,6 +190,7 @@ class MCPlayer : public MCControl
190190
{
191191
scale = s;
192192
}
193+
void scale_native_rect(void);
193194
Boolean prepare(const char *options);
194195
Boolean playstart(const char *options);
195196
Boolean playpause(Boolean on);

engine/src/stackview.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3131

3232
#include "tilecache.h"
3333
#include "redraw.h"
34+
#include "player.h"
3435

3536
////////////////////////////////////////////////////////////////////////////////
3637

@@ -210,6 +211,10 @@ void MCStack::view_set_content_scale(MCGFloat p_scale)
210211

211212
m_view_content_scale = p_scale;
212213

214+
// PM-2015-11-26: [[ Bug 13277 ]] Scale native player rect
215+
for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
216+
t_player -> scale_native_rect();
217+
213218
// IM-2014-01-16: [[ StackScale ]] Update view transform after changing view property
214219
view_update_transform(true);
215220
// IM-2014-10-22: [[ Bug 13746 ]] Update window mask when stack scale changes

0 commit comments

Comments
 (0)