Skip to content

Commit e0d617c

Browse files
author
runrevali
committed
Merge remote-tracking branch 'upstream/develop' into merge_6.7-rc-4_7.0
Conflicts: engine/engine.xcodeproj/project.pbxproj engine/src/lnximage.cpp
2 parents 78fb154 + 913e6e1 commit e0d617c

File tree

17 files changed

+213
-118
lines changed

17 files changed

+213
-118
lines changed

docs/notes/bugfix-13746.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# the shape property of stacks is broken

engine/engine.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@
681681
E82206E1184F810A00117D10 /* resolution.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E82206E0184F810A00117D10 /* resolution.cpp */; };
682682
E82206E2184F810A00117D10 /* resolution.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E82206E0184F810A00117D10 /* resolution.cpp */; };
683683
E864B42115BDAB5200F5361C /* legacy_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E864B41F15BDAB3F00F5361C /* legacy_spec.cpp */; };
684+
E8AF7D2319F7E3BF000F68E9 /* graphics_util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8AF7D2219F7E3BF000F68E9 /* graphics_util.cpp */; };
684685
E8DDE5E016C2B1A7007367E4 /* image_rep.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8DDE5DE16C2B1A7007367E4 /* image_rep.cpp */; };
685686
/* End PBXBuildFile section */
686687

@@ -1858,6 +1859,7 @@
18581859
E8A7EF0016FC98A200C39491 /* stacksecurity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stacksecurity.cpp; path = src/stacksecurity.cpp; sourceTree = "<group>"; };
18591860
E8AE103215D90DE700A517E8 /* exec-scripting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "exec-scripting.cpp"; path = "src/exec-scripting.cpp"; sourceTree = "<group>"; };
18601861
E8AF4890174D5563000B2F9E /* libskia.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libskia.xcodeproj; path = ../thirdparty/libskia/libskia.xcodeproj; sourceTree = SOURCE_ROOT; };
1862+
E8AF7D2219F7E3BF000F68E9 /* graphics_util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = graphics_util.cpp; path = src/graphics_util.cpp; sourceTree = "<group>"; };
18611863
E8DDE5DE16C2B1A7007367E4 /* image_rep.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = image_rep.cpp; path = src/image_rep.cpp; sourceTree = "<group>"; };
18621864
E8EBC31D13E04C29003F6AA3 /* srvmultipart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = srvmultipart.h; path = src/srvmultipart.h; sourceTree = "<group>"; };
18631865
E8EBC31E13E04C29003F6AA3 /* srvmultipart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srvmultipart.cpp; path = src/srvmultipart.cpp; sourceTree = "<group>"; };
@@ -3048,6 +3050,7 @@
30483050
4D592DEA14EED23600EADBB6 /* fonttable.cpp */,
30493051
4DB902510DAA5C980014A170 /* gradient.cpp */,
30503052
4DB902520DAA5C980014A170 /* gradient.h */,
3053+
E8AF7D2219F7E3BF000F68E9 /* graphics_util.cpp */,
30513054
4D587E370B8096FD00200116 /* mctheme.cpp */,
30523055
4D587DD90B8096E600200116 /* mctheme.h */,
30533056
4D587E7D0B8096FD00200116 /* metacontext.cpp */,
@@ -3998,6 +4001,7 @@
39984001
4D1F9D53171C682E0091C6CB /* hndlrlst.cpp in Sources */,
39994002
4D1F9D54171C682E0091C6CB /* idraw.cpp in Sources */,
40004003
4D1F9D55171C682E0091C6CB /* ifile.cpp in Sources */,
4004+
E8AF7D2419F7E3BF000F68E9 /* graphics_util.cpp in Sources */,
40014005
4D1F9D56171C682E0091C6CB /* igif.cpp in Sources */,
40024006
4D1F9D57171C682E0091C6CB /* iimport.cpp in Sources */,
40034007
4D1F9D58171C682E0091C6CB /* ijpg.cpp in Sources */,
@@ -4414,7 +4418,7 @@
44144418
7635171D182A8D3D00C31FA2 /* image_rep_densitymapped.cpp in Sources */,
44154419
4D77F1DD183F8298002EEBB4 /* exec-keywords.cpp in Sources */,
44164420
763FF4EA18522CC100B45FBA /* image_rep_resampled.cpp in Sources */,
4417-
4D6F2AE718981E7F0099947D /* (null) in Sources */,
4421+
E8AF7D2319F7E3BF000F68E9 /* graphics_util.cpp in Sources */,
44184422
4CF4B883199E0D9900E33AEE /* coretextlayout.mm in Sources */,
44194423
E82206E1184F810A00117D10 /* resolution.cpp in Sources */,
44204424
72C28AFA1911300D007F2AA0 /* segment.cpp in Sources */,

engine/src/desktop-image.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern void surface_extract_alpha(void *p_pixels, uint4 p_pixel_stride, void *p_
3131

3232
////////////////////////////////////////////////////////////////////////////////
3333

34-
MCWindowShape *MCImage::makewindowshape(void)
34+
MCWindowShape *MCImage::makewindowshape(const MCGIntegerSize &p_size)
3535
{
3636
bool t_success = true;
3737

@@ -42,7 +42,7 @@ MCWindowShape *MCImage::makewindowshape(void)
4242
uindex_t t_alpha_stride = 0;
4343
uindex_t t_width, t_height;
4444

45-
t_success = lockbitmap(t_bitmap, true);
45+
t_success = lockbitmap(true, true, &p_size, t_bitmap);
4646

4747
if (t_success)
4848
t_success = MCImageBitmapHasTransparency(t_bitmap);

engine/src/desktop-stack.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ void MCStack::updatewindowshape(MCWindowShape *p_shape)
339339
{
340340
destroywindowshape();
341341
m_window_shape = p_shape;
342-
MCPlatformSetWindowProperty(window, kMCPlatformWindowPropertyMask, kMCPlatformPropertyTypeWindowMask, (MCPlatformWindowMaskRef *)&m_window_shape -> handle);
342+
// IM-2014-10-22: [[ Bug 13746 ]] Check for platform window before setting mask
343+
if (window != nil)
344+
MCPlatformSetWindowProperty(window, kMCPlatformWindowPropertyMask, kMCPlatformPropertyTypeWindowMask, (MCPlatformWindowMaskRef *)&m_window_shape -> handle);
343345
dirtyall();
344346
}
345347

engine/src/exec-interface-stack.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,18 +1767,8 @@ void MCStack::SetWindowShape(MCExecContext& ctxt, uinteger_t p_shape)
17671767
t_image = resolveimageid(windowshapeid);
17681768
if (t_image != NULL)
17691769
{
1770-
MCWindowShape *t_new_mask;
1771-
setextendedstate(True, ECS_MASK_CHANGED);
1772-
t_image -> setflag(True, F_I_ALWAYS_BUFFER);
1773-
t_image -> open();
1774-
t_new_mask = t_image -> makewindowshape();
1775-
t_image -> close();
1776-
// MW-2014-06-11: [[ Bug 12495 ]] Refactored action as different whether using platform API or not.
1777-
// MW-2014-07-29: [[ Bug 12997 ]] Merge error - refactored code from 6.7 not integrated.
1778-
if (t_new_mask != NULL)
1779-
updatewindowshape(t_new_mask);
1780-
1781-
// Update window mask immediately changes things so no need to reopenwindow.
1770+
// IM-2014-10-22: [[ Bug 13746 ]] use common loadwindowshape() method
1771+
loadwindowshape();
17821772
return;
17831773
}
17841774
}

engine/src/graphics_util.cpp

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/* Copyright (C) 2003-2013 Runtime Revolution Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
17+
#include "graphics.h"
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
21+
// IM-2014-10-22: [[ Bug 13746 ]] Set the given rect of the raster to transparent black
22+
void MCGRasterClearRect(MCGRaster &x_raster, const MCGIntegerRectangle &p_rect)
23+
{
24+
MCGIntegerRectangle t_coverage;
25+
t_coverage = MCGIntegerRectangleIntersection(p_rect, MCGIntegerRectangleMake(0, 0, x_raster.width, x_raster.height));
26+
27+
if (MCGIntegerRectangleIsEmpty(t_coverage))
28+
return;
29+
30+
uint8_t *t_pixel_ptr;
31+
t_pixel_ptr = (uint8_t*)x_raster.pixels;
32+
33+
if (t_coverage.origin.y > 0)
34+
t_pixel_ptr += t_coverage.origin.y * x_raster.stride;
35+
if (t_coverage.origin.x > 0)
36+
t_pixel_ptr += t_coverage.origin.x * sizeof(uint32_t);
37+
38+
uint32_t t_width;
39+
t_width = t_coverage.size.width * sizeof(uint32_t);
40+
41+
for (uint32_t y = 0; y < t_coverage.size.height; y++)
42+
{
43+
MCMemoryClear(t_pixel_ptr, t_width);
44+
t_pixel_ptr += x_raster.stride;
45+
}
46+
}
47+
48+
// IM-2014-10-03: [[ Bug 13432 ]] Set the alpha values of the opaque image from the alpha raster, premultiplying the pixels
49+
void MCGRasterApplyAlpha(MCGRaster &x_raster, const MCGRaster &p_alpha, const MCGIntegerPoint &p_offset)
50+
{
51+
MCAssert(p_alpha.format == kMCGRasterFormat_A);
52+
MCAssert(x_raster.format == kMCGRasterFormat_xRGB);
53+
54+
MCGIntegerRectangle t_coverage;
55+
t_coverage = MCGIntegerRectangleIntersection(MCGIntegerRectangleMake(0, 0, x_raster.width, x_raster.height),
56+
MCGIntegerRectangleMake(p_offset.x, p_offset.y, p_alpha.width, p_alpha.height));
57+
58+
if (MCGIntegerRectangleIsEmpty(t_coverage))
59+
{
60+
// IM-2014-10-22: [[ Bug 13746 ]] If the mask is not within the region of the raster then blank out everything
61+
MCGRasterClearRect(x_raster, MCGIntegerRectangleMake(0, 0, x_raster.width, x_raster.height));
62+
x_raster.format = kMCGRasterFormat_ARGB;
63+
return;
64+
}
65+
66+
// IM-2014-10-22: [[ Bug 13746 ]] Areas outside the mask need to be blanked out
67+
int32_t t_left, t_top, t_right, t_bottom;
68+
t_left = t_coverage.origin.x;
69+
t_top = t_coverage.origin.y;
70+
t_right = t_coverage.origin.x + t_coverage.size.width;
71+
t_bottom = t_coverage.origin.y + t_coverage.size.height;
72+
73+
MCGRasterClearRect(x_raster, MCGIntegerRectangleMakeLTRB(0, 0, x_raster.width, t_top));
74+
MCGRasterClearRect(x_raster, MCGIntegerRectangleMakeLTRB(0, t_bottom, x_raster.width, x_raster.height));
75+
MCGRasterClearRect(x_raster, MCGIntegerRectangleMakeLTRB(0, t_top, t_left, t_bottom));
76+
MCGRasterClearRect(x_raster, MCGIntegerRectangleMakeLTRB(t_right, t_top, x_raster.width, t_bottom));
77+
78+
uint8_t *t_alpha_ptr;
79+
t_alpha_ptr = (uint8_t*)p_alpha.pixels;
80+
81+
if (p_offset.y < 0)
82+
t_alpha_ptr += p_alpha.stride * (-p_offset.y);
83+
if (p_offset.x < 0)
84+
t_alpha_ptr += (-p_offset.x);
85+
86+
uint8_t *t_pixel_ptr;
87+
t_pixel_ptr = (uint8_t*)x_raster.pixels;
88+
89+
if (t_coverage.origin.y > 0)
90+
t_pixel_ptr += x_raster.stride * t_coverage.origin.y;
91+
if (t_coverage.origin.x > 0)
92+
t_pixel_ptr += t_coverage.origin.x * sizeof(uint32_t);
93+
94+
for (uint32_t y = 0; y < t_coverage.size.height; y++)
95+
{
96+
uint8_t *t_alpha_row;
97+
t_alpha_row = t_alpha_ptr;
98+
99+
uint32_t *t_pixel_row;
100+
t_pixel_row = (uint32_t*)t_pixel_ptr;
101+
102+
for (uint32_t x = 0; x < t_coverage.size.width; x++)
103+
{
104+
uint32_t t_pixel;
105+
t_pixel = *t_pixel_row;
106+
107+
uint8_t t_alpha;
108+
t_alpha = *t_alpha_row++;
109+
110+
*t_pixel_row++ = MCGPixelPreMultiplyNative(MCGPixelSetNativeAlpha(t_pixel, t_alpha));
111+
}
112+
//
113+
114+
t_alpha_ptr += p_alpha.stride;
115+
t_pixel_ptr += x_raster.stride;
116+
}
117+
118+
x_raster.format = kMCGRasterFormat_ARGB;
119+
}
120+
121+
////////////////////////////////////////////////////////////////////////////////

engine/src/graphics_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,10 @@ static inline MCGFont MCFontStructToMCGFont(MCFontStruct *p_font)
371371

372372
#endif
373373

374+
////////////////////////////////////////////////////////////////////////////////
375+
376+
// IM-2014-10-22: [[ Bug 13746 ]] Raster modifying utility functions
377+
void MCGRasterClearRect(MCGRaster &x_raster, const MCGIntegerRectangle &p_rect);
378+
void MCGRasterApplyAlpha(MCGRaster &x_raster, const MCGRaster &p_alpha, const MCGIntegerPoint &p_offset);
379+
374380
#endif // __GRAPHICS_UTIL_H_

engine/src/image.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ class MCImage : public MCControl
549549
bool getclipboardtext(MCDataRef& r_data);
550550

551551
// MW-2011-09-13: [[ Masks ]] Updated to return a 'MCWindowMask'
552-
MCWindowShape *makewindowshape(void);
552+
// IM-2014-10-22: [[ Bug 13746 ]] Add size parameter to allow scaled window shapes
553+
MCWindowShape *makewindowshape(const MCGIntegerSize &p_size);
553554

554555
#if defined(_MAC_DESKTOP)
555556
CGImageRef makeicon(uint4 p_width, uint4 p_height);

engine/src/lnximage.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2727
#include "lnxdc.h"
2828
#include "imagebitmap.h"
2929

30+
#include "graphics.h"
31+
32+
// Linux image conversion functions
3033
bool MCImageBitmapCreateWithGdkPixbuf(GdkPixbuf *p_image, MCImageBitmap *&r_bitmap)
3134
{
3235
MCImageBitmap *t_bitmap;
@@ -186,7 +189,7 @@ bool MCPatternToX11Pixmap(MCPatternRef p_pattern, Pixmap &r_pixmap)
186189
}
187190

188191
void surface_extract_alpha(void *p_pixels, uint4 p_pixel_stride, void *p_alpha, uint4 p_alpha_stride, uint4 p_width, uint4 p_height);
189-
MCWindowShape *MCImage::makewindowshape(void)
192+
MCWindowShape *MCImage::makewindowshape(const MCGIntegerSize &p_size)
190193
{
191194
bool t_success;
192195
t_success = true;
@@ -195,15 +198,17 @@ MCWindowShape *MCImage::makewindowshape(void)
195198
if (!MCMemoryNew(t_mask))
196199
return nil;
197200

198-
// Get the width / height.
199-
t_mask -> width = rect . width;
200-
t_mask -> height = rect . height;
201-
202201
MCImageBitmap *t_bitmap = nil;
203202
bool t_has_mask = false, t_has_alpha = false;
204-
t_success = lockbitmap(t_bitmap, true);
203+
204+
t_success = lockbitmap(true, true, &p_size, t_bitmap);
205+
205206
if (t_success)
206207
{
208+
// Get the width / height.
209+
t_mask -> width = t_bitmap->width;
210+
t_mask -> height = t_bitmap->height;
211+
207212
t_has_mask = MCImageBitmapHasTransparency(t_bitmap, t_has_alpha);
208213
#ifdef LIBGRAPHICS_BROKEN
209214
if (t_has_alpha)

engine/src/mac-av-player.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,20 @@ - (void)setPlayer:(AVPlayer *)player
818818
// pause at the endtime.
819819
if (m_play_selection_only)
820820
{
821-
CMTime t_end_time;
821+
// MW-2014-10-22: [[ Bug 13267 ]] Boundary time observers often go 'past' the requested time by a small amount
822+
// so we set the boundary to be one timescale unit before the actual end time, and then adjust when we hit
823+
// that time.
824+
CMTime t_end_time, t_original_end_time;
822825
if (m_selection_duration != 0)
823826
t_end_time = CMTimeFromLCTime(m_selection_finish);
824827
else
825828
t_end_time = [m_player currentItem] . asset . duration;
829+
t_original_end_time = t_end_time;
830+
t_end_time . value -= 1;
826831
m_endtime_observer_token = [m_player addBoundaryTimeObserverForTimes: [NSArray arrayWithObject: [NSValue valueWithCMTime: t_end_time]]
827832
queue: nil usingBlock: ^(void) {
828833
[m_player pause];
834+
[m_player seekToTime: t_original_end_time toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
829835
}];
830836
}
831837

0 commit comments

Comments
 (0)