19 #include "../basic_types.h"
20 #include "../scene/scene.h"
21 #include "../exception.h"
22 #include "../color/constants.h"
31 std::string log = prefix +
"Scene has " +
std::to_string(
scene.getLayerCount()) +
" layers\n";
32 const int N =
scene.getLayerCount();
33 for (
int i = 0; i < N; i++) {
48 log +=
"masked bitmap";
65 log +=
", no content";
83 if (recursionLeft > 0)
99 std::string candidate;
116 return newLayer<BitmapLayer>(
name);
126 return newLayer<MaskedBitmapLayer>(
name);
136 return newLayer<ShapedBitmapLayer>(
name);
146 return newLayer<ShadedBitmapLayer>(
name);
165 if (l->getName() ==
name)
176 for (
auto it =
layers.crbegin(); it !=
layers.crend(); it++)
177 if (!(*it)->isPhantom()) {
183 if ((*it)->testPoint(
x,
y))
192 for (
size_t i = 0; i <
layers.size(); ++i)
200 return (
int)
layers.size();
205 for (
auto it =
layers.crbegin(); it !=
layers.crend(); it++) {
252 return getChild(
x,
y) !=
nullptr;
256 static const unsigned int MAX_RECURSION_DEPTH = 256;
257 if (recursionDepth >= MAX_RECURSION_DEPTH)
260 return scene.getLayer(
p.
x,
p.
y, recursionDepth);
269 Layer(type), invAr(0),
bitmap(nullptr), bitmapMapping(), modulation(Color::
WHITE)
281 invAr =
content->getInvAspectRatio();
295 switch (
content->getTextureFormat()) {
296 case GL::TextureHandler::TextureFormat::OES_Ext:
318 return (
mapping * bitmapMapping).isPointInside(
x,
y, 1, invAr);
328 AffineMapping arImgMapping(bitmapMapping), arMaskMapping(maskMapping);
329 arImgMapping.matrix.scale(1.0f, invAr);
349 switch (
content->getTextureFormat()) {
350 case GL::TextureHandler::TextureFormat::OES_Ext:
384 bool result = mask->getPixelInt(
w,
h) > 0;
395 borderWidth(0), slopeWidth(0), cornerRadius(0),
inPixels(true)
404 switch (
content->getTextureFormat()) {
405 case GL::TextureHandler::TextureFormat::OES_Ext:
454 invAr =
content->getInvAspectRatio();
464 shader->process(context.
getGpu());
Locks a bitmap for reading on CPU.
std::string toString() const
Retruns a string describing the bitmap.
2x3 affine mapping containing a 2x2 matrix and a 2D point
AffineMapping getInverse() const
Returns inverse mapping.
bool isPointInside(const Point &point) const
Tests whether a point from the output domain is inside the input axes span.
void scale(numeric factor)
Base class for all exceptions.
void bindSampler(GraphicPipeline &gpu, GL::TextureHandler &image, const char *uniformId, TextureParam param)
void setFloat(const std::string &name, const float value, bool safe=false)
Assigns a value to a specific floating point variable in the program.
void setVector4(const std::string &name, const float x, const float y, const float z, const float w)
void setMatrix3(const std::string &name, const Matrix2 &mat, const Point &pos)
void setVector2(const std::string &name, const float x, const float y)
@ MASKED_BLEND_EXT
blending an image through a pixelwise mask (texture extension)
@ MASKED_8BIT_BLEND_EXT
blending an image through a 8 bit pixelwise mask (texture extension)
@ SHAPED_BLEND
shaping an image
@ BLEND_EXT
default blending using a texture extension
@ MASKED_8BIT_BLEND
blending an image through a 8 bit pixelwise mask
@ MASKED_BLEND
blending an image through a pixelwise mask
@ SHAPED_BLEND_EXT
shaping an image (texture extension)
@ BLEND
default blending of a single image
static const char * VERTICAL_FLIP_ID
Vertical flipping variable name in vertex shader.
static const char * MODELVIEW_MATRIX_ID
Modelview matrix (mapping input geometry to output) shader variable name in vertex shader.
float getInvAspectRatio() const
Stores the rendering context: current program, current mapping in the scene space,...
void blend()
Initiates the rendering operation.
const float getOutputWidth() const
void bindMask(AbstractBitmap &mask)
const AffineMapping & getMapping() const
const bool isRenderingOnScreen() const
GL::Program & getProgram()
GraphicPipeline & getGpu()
const ImageResolution & getOutputResolution() const
void enableProgram(GL::RenderingPrograms::Operation operation)
void lockBitmap(AbstractBitmap *bitmap)
static void check(const bool condition, const std::string &message)
Layer having an image to render.
GL::TextureHandler * resolveContent(RenderingContext &context)
const AbstractBitmap * getBitmap() const
void render(RenderingContext &context)
void configure(RenderingContext &context, GL::TextureHandler *content)
Configures current rendering program to render this layer.
bool testPoint(float x, float y) const
Tests if a given point falls in the layer.
Layer containing a bitmap and a mask applied to the bitmap when rendering.
void configure(RenderingContext &context, GL::TextureHandler *content)
CustomMaskedBitmapLayer(Type type)
Abstract scene layer having name, type, geometry and some content to display.
virtual bool testPoint(float x, float y) const
Tests if a given point falls in the layer.
@ SceneLayer
layer containing a scene
@ MaskedBitmapLayer
layer displaying a bitmap with mask
@ ShadedBitmapLayer
layer displaying a bitmap through a custom fragment shader
@ BitmapLayer
layer displaying a bitmap
@ ShapedBitmapLayer
layer displaying a bitmap within a shape
void setName(const char *name)
virtual Layer * getChild(float x, float y, unsigned int recursionDepth=0) const
Picks a child layer at given point, if any.
const std::string & getName() const
bool isPhantom() const
Returns true if the layer is ignored when searching a layer by point.
AffineMapping & getMapping()
LayerType & castTo() const
Layer(const Layer &)=delete
disabling copying constructor
Bitmap layer using another bitmap as a mask.
bool testPoint(float x, float y) const
Tests if a given point falls in the layer.
void render(RenderingContext &context)
const AbstractBitmap * getMask() const
std::string getSceneLog(const Scene &scene, const std::string prefix, int recursionLeft=100) const
SceneIntegrityError(const std::string reason, const Scene &scene)
Layer containing an entire scene.
SceneLayer(const Beatmup::Scene &scene)
Layer * getChild(float x, float y, unsigned int recursionDepth=0) const
Picks a child layer at given point, if any.
bool testPoint(float x, float y) const
Tests if a given point falls in the layer.
const Beatmup::Scene & getScene() const
Bitmap layer using a custom shader.
void render(RenderingContext &context)
Layer containing a bitmap and a parametric mask (shape)
void render(RenderingContext &context)
bool testPoint(float x, float y) const
Tests if a given point falls in the layer.
An ordered set of layers representing a renderable content.
ShadedBitmapLayer & newShadedBitmapLayer()
bool resolveMapping(const Layer &layer, AffineMapping &mapping) const
Computes absolute mapping of a given layer with respect to the scene mapping.
void attachLayer(Layer &layer)
Attaches an existing layer to the scene.
MaskedBitmapLayer & newMaskedBitmapLayer()
Layer * getLayer(const char *name) const
Retrieves a layer by its name or null if not found.
BitmapLayer & newBitmapLayer()
Layer * detachLayer(int index)
Detaches a layer from the scene.
int getLayerCount() const
Returns total number of layers in the scene.
std::vector< Layer * > layers
scene layers
ShapedBitmapLayer & newShapedBitmapLayer()
int getLayerIndex(const Layer &layer) const
Returns layer index in the scene or -1 if not found.
SceneLayer & addScene(const Scene &scene)
Adds a subscene to the current scene.
static const color4i ZERO
static const color4i WHITE
CustomPoint< float > Point
@ SingleByte
single channel of 8 bits per pixel (like grayscale), unsigned integer values
@ INTERP_LINEAR
bilinear pixel interpolation
std::string to_string(Beatmup::NNets::ActivationFunction function)
std::string generateUniqueLayerName(const Scene &scene, const char *prefix="")
JNIEnv jlong jint jint jint jint jfloat scale
return(jlong) new Beatmup jlong jstring name
jobject jlong jint jint y
jlong jstring jint jint jint jint w
Beatmup::InternalBitmap * bitmap
Beatmup::Scene::Layer * layer
Beatmup::IntPoint p((int) x,(int) y)
return $pool getJavaReference & scene(index)
return bitmap getHeight()
Beatmup::AffineMapping & mapping
return layer isVisible() ? JNI_TRUE jlong jboolean phantom