Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ class FlxCamera extends FlxBasic
public function drawPixels(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false,
?shader:FlxShader):Void
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
_helperMatrix.copyFrom(matrix);
Expand All @@ -759,6 +760,7 @@ class FlxCamera extends FlxBasic
}
}
else
#end
{
var isColored = (transform != null #if !html5 && transform.hasRGBMultipliers() #end);
var hasColorOffsets:Bool = (transform != null && transform.hasRGBAOffsets());
Expand All @@ -775,6 +777,7 @@ class FlxCamera extends FlxBasic
public function copyPixels(?frame:FlxFrame, ?pixels:BitmapData, ?sourceRect:Rectangle, destPoint:Point, ?transform:ColorTransform, ?blend:BlendMode,
?smoothing:Bool = false, ?shader:FlxShader):Void
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
if (pixels != null)
Expand All @@ -800,6 +803,7 @@ class FlxCamera extends FlxBasic
}
}
else
#end
{
_helperMatrix.identity();
_helperMatrix.translate(destPoint.x + frame.offset.x, destPoint.y + frame.offset.y);
Expand All @@ -821,6 +825,7 @@ class FlxCamera extends FlxBasic
{
final cameraBounds = _bounds.set(viewMarginLeft, viewMarginTop, viewWidth, viewHeight);

#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
if (position == null)
Expand Down Expand Up @@ -894,6 +899,7 @@ class FlxCamera extends FlxBasic
bounds.put();
}
else
#end
{
final isColored = (colors != null && colors.length != 0) || (transform != null && transform.hasRGBMultipliers());
final hasColorOffsets = (transform != null && transform.hasRGBAOffsets());
Expand All @@ -908,8 +914,12 @@ class FlxCamera extends FlxBasic
* @param rect rectangle to prepare for rendering
* @return transformed rectangle with respect to camera's zoom factor
*/
#if FLX_NO_RENDER_BLIT
@:deprecated("transformRect will be removed")
#end
function transformRect(rect:FlxRect):FlxRect
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
rect.offset(-viewMarginLeft, -viewMarginTop);
Expand All @@ -922,6 +932,7 @@ class FlxCamera extends FlxBasic
rect.height *= zoom;
}
}
#end

return rect;
}
Expand All @@ -931,15 +942,20 @@ class FlxCamera extends FlxBasic
* @param point point to prepare for rendering
* @return transformed point with respect to camera's zoom factor
*/
#if FLX_NO_RENDER_BLIT
@:deprecated("transformPoint will be removed")
#end
function transformPoint(point:FlxPoint):FlxPoint
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
point.subtract(viewMarginLeft, viewMarginTop);

if (_useBlitMatrix)
point.scale(zoom);
}
#end

return point;
}
Expand All @@ -949,10 +965,15 @@ class FlxCamera extends FlxBasic
* @param vector relative position to prepare for rendering
* @return transformed vector with respect to camera's zoom factor
*/
#if FLX_NO_RENDER_BLIT
@:deprecated("transformVector will be removed")
#end
inline function transformVector(vector:FlxPoint):FlxPoint
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit && _useBlitMatrix)
vector.scale(zoom);
#end

return vector;
}
Expand Down Expand Up @@ -1013,6 +1034,7 @@ class FlxCamera extends FlxBasic

pixelPerfectRender = FlxG.renderBlit;

#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
screen = new FlxSprite();
Expand All @@ -1024,6 +1046,7 @@ class FlxCamera extends FlxBasic
_fill = new BitmapData(width, height, true, FlxColor.TRANSPARENT);
}
else
#end
{
canvas = new Sprite();
_scrollRect.addChild(canvas);
Expand Down Expand Up @@ -1054,6 +1077,7 @@ class FlxCamera extends FlxBasic
{
FlxDestroyUtil.removeChild(flashSprite, _scrollRect);

#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
FlxDestroyUtil.removeChild(_scrollRect, _flashBitmap);
Expand All @@ -1063,6 +1087,7 @@ class FlxCamera extends FlxBasic
_fill = FlxDestroyUtil.dispose(_fill);
}
else
#end
{
#if FLX_DEBUG
FlxDestroyUtil.removeChild(_scrollRect, debugLayer);
Expand Down Expand Up @@ -1394,6 +1419,7 @@ class FlxCamera extends FlxBasic
*/
function updateInternalSpritePositions():Void
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
if (_flashBitmap != null)
Expand All @@ -1403,6 +1429,7 @@ class FlxCamera extends FlxBasic
}
}
else
#end
{
if (canvas != null)
{
Expand Down Expand Up @@ -1643,6 +1670,7 @@ class FlxCamera extends FlxBasic
*/
public function fill(Color:FlxColor, BlendAlpha:Bool = true, FxAlpha:Float = 1.0, ?graphics:Graphics):Void
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
if (BlendAlpha)
Expand All @@ -1656,6 +1684,7 @@ class FlxCamera extends FlxBasic
}
}
else
#end
{
final targetGraphics = (graphics == null) ? canvas.graphics : graphics;

Expand All @@ -1677,13 +1706,15 @@ class FlxCamera extends FlxBasic
// Draw the "flash" special effect onto the buffer
if (_fxFlashAlpha > 0.0)
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
var color = _fxFlashColor;
color.alphaFloat *= _fxFlashAlpha;
fill(color);
}
else
#end
{
final alpha = _fxFlashColor.alphaFloat * _fxFlashAlpha;
fill(_fxFlashColor.rgb, true, alpha, canvas.graphics);
Expand All @@ -1693,13 +1724,15 @@ class FlxCamera extends FlxBasic
// Draw the "fade" special effect onto the buffer
if (_fxFadeAlpha > 0.0)
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
var color = _fxFadeColor;
color.alphaFloat *= _fxFadeAlpha;
fill(color);
}
else
#end
{
final alpha = _fxFadeColor.alphaFloat * _fxFadeAlpha;
fill(_fxFadeColor.rgb, true, alpha, canvas.graphics);
Expand All @@ -1708,8 +1741,12 @@ class FlxCamera extends FlxBasic
}

@:allow(flixel.system.frontEnds.CameraFrontEnd)
#if FLX_NO_RENDER_BLIT
@:deprecated("checkResize is deprecated")
#end
function checkResize():Void
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
if (width != buffer.width || height != buffer.height)
Expand All @@ -1728,8 +1765,12 @@ class FlxCamera extends FlxBasic

updateBlitMatrix();
}
#end
}

#if FLX_NO_RENDER_BLIT
@:deprecated("updateBlitMatrix is deprecated")
#end
inline function updateBlitMatrix():Void
{
_blitMatrix.identity();
Expand Down Expand Up @@ -1816,6 +1857,7 @@ class FlxCamera extends FlxBasic
totalScaleX = scaleX * FlxG.scaleMode.scale.x;
totalScaleY = scaleY * FlxG.scaleMode.scale.y;

#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
updateBlitMatrix();
Expand All @@ -1831,6 +1873,7 @@ class FlxCamera extends FlxBasic
_flashBitmap.scaleY = totalScaleY;
}
}
#end

calcMarginX();
calcMarginY();
Expand Down Expand Up @@ -1929,11 +1972,13 @@ class FlxCamera extends FlxBasic
function set_alpha(Alpha:Float):Float
{
alpha = FlxMath.bound(Alpha, 0, 1);
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
_flashBitmap.alpha = Alpha;
}
else
#end
{
canvas.alpha = Alpha;
}
Expand All @@ -1952,6 +1997,7 @@ class FlxCamera extends FlxBasic
color = Color;
var colorTransform:ColorTransform;

#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
if (_flashBitmap == null)
Expand All @@ -1961,6 +2007,7 @@ class FlxCamera extends FlxBasic
colorTransform = _flashBitmap.transform.colorTransform;
}
else
#end
{
colorTransform = canvas.transform.colorTransform;
}
Expand All @@ -1969,11 +2016,13 @@ class FlxCamera extends FlxBasic
colorTransform.greenMultiplier = color.greenFloat;
colorTransform.blueMultiplier = color.blueFloat;

#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
_flashBitmap.transform.colorTransform = colorTransform;
}
else
#end
{
canvas.transform.colorTransform = colorTransform;
}
Expand All @@ -1984,10 +2033,12 @@ class FlxCamera extends FlxBasic
function set_antialiasing(Antialiasing:Bool):Bool
{
antialiasing = Antialiasing;
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
_flashBitmap.smoothing = Antialiasing;
}
#end
return Antialiasing;
}

Expand Down
7 changes: 6 additions & 1 deletion flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class FlxG

public static var renderMethod(default, null):FlxRenderMethod;

@:deprecated("renderBlit will be removed")
public static var renderBlit(default, null):Bool;
public static var renderTile(default, null):Bool;

Expand Down Expand Up @@ -584,6 +585,7 @@ class FlxG

static function initRenderMethod():Void
{
#if FLX_RENDER_BLIT
#if !flash
renderMethod = switch (stage.window.context.type)
{
Expand All @@ -601,6 +603,9 @@ class FlxG
#if air
renderMethod = BLITTING;
#end
#else
renderMethod = DRAW_TILES;
#end

renderBlit = renderMethod == BLITTING;
renderTile = renderMethod == DRAW_TILES;
Expand Down Expand Up @@ -747,5 +752,5 @@ class FlxG
enum FlxRenderMethod
{
DRAW_TILES;
BLITTING;
@:deprecated BLITTING;
}
7 changes: 7 additions & 0 deletions flixel/FlxObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1298,21 +1298,28 @@ class FlxObject extends FlxBasic

inline function beginDrawDebug(camera:FlxCamera):Graphics
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
{
FlxSpriteUtil.flashGfx.clear();
return FlxSpriteUtil.flashGfx;
}
else
#end
{
return camera.debugLayer.graphics;
}
}

#if FLX_NO_RENDER_BLIT
@:deprecated("endDrawDebug is deprecated")
#end
inline function endDrawDebug(camera:FlxCamera)
{
#if FLX_RENDER_BLIT
if (FlxG.renderBlit)
camera.buffer.draw(FlxSpriteUtil.flashGfxSprite);
#end
}
#end

Expand Down
Loading