Skip to content

Commit fe551df

Browse files
committed
[[ RefactorGraphics ]] Finished getting bitmap effects to work (spread still to implement).
1 parent 4bf77d7 commit fe551df

5 files changed

Lines changed: 659 additions & 435 deletions

File tree

engine/src/graphicscontext.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static inline MCGBlendMode MCBitmapEffectBlendModeToMCGBlendMode(MCBitmapEffectB
7777
}
7878
}
7979

80-
static void MCGraphicsContextAngleAndDistanceToXYOffset(uint8_t p_angle, uint8_t p_distance, MCGFloat &r_x_offset, MCGFloat &r_y_offset)
80+
static void MCGraphicsContextAngleAndDistanceToXYOffset(int p_angle, int p_distance, MCGFloat &r_x_offset, MCGFloat &r_y_offset)
8181
{
8282
r_x_offset = floor(0.5f + p_distance * cos(p_angle * M_PI / 180.0));
8383
r_y_offset = floor(0.5f + p_distance * sin(p_angle * M_PI / 180.0));
@@ -191,10 +191,11 @@ bool MCGraphicsContext::begin_with_effects(MCBitmapEffectsRef p_effects, const M
191191
t_x_offset, t_y_offset);
192192
t_effects . drop_shadow . x_offset = t_x_offset;
193193
t_effects . drop_shadow . y_offset = t_y_offset;
194+
t_effects . drop_shadow . knockout = p_effects -> effects[kMCBitmapEffectTypeDropShadow] . shadow . knockout;
194195
}
195196
else
196-
t_effects . has_drop_shadow = false;
197-
197+
t_effects . has_drop_shadow = false;
198+
198199
MCGContextBeginWithEffects(m_gcontext, MCGRectangleMake(p_shape . x, p_shape . y, p_shape . width, p_shape . height), t_effects);
199200
return true;
200201
}

libgraphics/include/graphics.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ inline MCGRectangle MCGRectangleTranslate(MCGRectangle p_rect, MCGFloat p_dx, MC
293293
return t_rect;
294294
}
295295

296-
static inline MCGRectangle MCGRectangleScale(MCGRectangle p_rect, MCGFloat p_scale)
296+
inline MCGRectangle MCGRectangleScale(MCGRectangle p_rect, MCGFloat p_scale)
297297
{
298298
MCGRectangle t_rect;
299299
t_rect.origin.x = p_rect.origin.x * p_scale;
@@ -314,6 +314,14 @@ inline MCGPoint MCGPointMake(MCGFloat p_x, MCGFloat p_y)
314314
return t_point;
315315
}
316316

317+
inline MCGSize MCGSizeMake(MCGFloat p_w, MCGFloat p_h)
318+
{
319+
MCGSize t_size;
320+
t_size . width = p_w;
321+
t_size . height = p_h;
322+
return t_size;
323+
}
324+
317325
////////////////////////////////////////////////////////////////////////////////
318326

319327
// Create new image with pixel data copied from raster

libgraphics/src/blur.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
/*
2+
* Copyright 2006 The Android Open Source Project
3+
*
4+
* Use of this source code is governed by a BSD-style license that can be
5+
* found in the LICENSE file.
6+
*/
7+
18
#include "graphics.h"
9+
#include "graphics-internal.h"
210

311
#include <SkMath.h>
412
#include <SkMask.h>
13+
#include <SkColorPriv.h>
514

615
#define kBlurRadiusFudgeFactor SkFloatToScalar( .57735f )
716

@@ -316,7 +325,7 @@ static void get_adjusted_radii(SkScalar passRadius, int *loRadius, int *hiRadius
316325
// radius -= p1_radius
317326
// pass 2 is (radius + (3 - 2 - 1)) / (3 - 2) = (radius + 0) / 1 (3)
318327

319-
bool MCGBlurBox(const SkMask& p_src, SkScalar p_x_radius, SkScalar p_y_radius, SkMask& r_dst)
328+
bool MCGBlurBox(const SkMask& p_src, SkScalar p_x_radius, SkScalar p_y_radius, SkScalar p_spread, SkMask& r_dst)
320329
{
321330
int t_pass_count;
322331
t_pass_count = 3;
@@ -333,9 +342,6 @@ bool MCGBlurBox(const SkMask& p_src, SkScalar p_x_radius, SkScalar p_y_radius, S
333342
wx = 255 - SkScalarRound((SkIntToScalar(rx) - px) * 255);
334343
wy = 255 - SkScalarRound((SkIntToScalar(ry) - py) * 255);
335344

336-
if (rx <= 0 || ry <= 0)
337-
return false;
338-
339345
int t_pad_x, t_pad_y;
340346
t_pad_x = rx;
341347
t_pad_y = ry;
@@ -445,7 +451,7 @@ bool MCGBlurBox(const SkMask& p_src, SkScalar p_x_radius, SkScalar p_y_radius, S
445451

446452
int ry_lo, ry_hi;
447453
ry_lo = ry_hi = sry;
448-
//get_adjusted_radii(py, &ry_lo, &ry_hi);
454+
449455
h = boxBlur(tp, h, dp, ry_lo, ry_hi, h, w, false);
450456

451457
sry = (r + 1) / 2;

0 commit comments

Comments
 (0)