+ core::pixel_format_desc pfd(core::pixel_format::bgra);
+ pfd.planes.push_back(core::pixel_format_desc::plane(psd_layer->bitmap()->width(), psd_layer->bitmap()->height(), 4));
+
+ auto frame = dependencies.frame_factory->create_frame(it->get(), pfd, core::audio_channel_layout::invalid());
+ auto destination = frame.image_data().data();
+ auto source = psd_layer->bitmap()->data();
+ memcpy(destination, source, frame.image_data().size());
+
+ layer_producer = core::create_const_producer(core::draw_frame(std::move(frame)), psd_layer->bitmap()->width(), psd_layer->bitmap()->height());
+ }
+ else {
+ CASPAR_LOG(warning) << "Ignoring layer \"" << layer_name << "\", layer type not supported";
+ }
+
+ if(layer_producer)
+ scene_layer = ¤t.scene()->create_layer(spl::make_shared_ptr(layer_producer), psd_layer->location().x + adjustment_x, psd_layer->location().y + adjustment_y, layer_name);
+ }
+
+ if (layer_producer && scene_layer)
+ {
+ scene_layer->adjustments.opacity.set(psd_layer->opacity() / 255.0);
+ scene_layer->hidden.set(!psd_layer->is_visible()); //this will always evaluate to true
+ scene_layer->blend_mode.set(psd_layer->blend_mode());
+ scene_layer->rotation.set(psd_layer->angle());
+
+ if (psd_layer->mask().has_vector()) {
+
+ if (psd_layer->is_placeholder() && psd_layer->is_cornerpin()) {
+
+ psd::point<int> layer_pos{ static_cast<int>(scene_layer->position.x.get()), static_cast<int>(scene_layer->position.y.get()) };
+ auto unbind_and_set = [&layer_pos](caspar::core::scene::coord& c, const caspar::psd::point<int>& pt) {
+ c.x.unbind();
+ c.x.set(pt.x - layer_pos.x); //remap to layer-coordinates
+ c.y.unbind();
+ c.y.set(pt.y - layer_pos.y); //remap to layer-coordinates
+ };
+
+ if (!psd_layer->mask().vector()->rect().empty()) {
+ //this rectangle is in document-coordinates
+ auto& mask = psd_layer->mask().vector()->rect();
+
+ unbind_and_set(scene_layer->perspective.upper_left, mask.location);
+ unbind_and_set(scene_layer->perspective.upper_right, point<int>{mask.location.x + mask.size.width, mask.location.y});
+ unbind_and_set(scene_layer->perspective.lower_right, point<int>{mask.location.x + mask.size.width, mask.location.y + mask.size.width});
+ unbind_and_set(scene_layer->perspective.lower_left, point<int>{mask.location.x, mask.location.y + mask.size.width});
+ }
+ else if (!psd_layer->mask().vector()->knots().empty()) {
+ auto& knots = psd_layer->mask().vector()->knots();
+ unbind_and_set(scene_layer->perspective.upper_left, knots[0]);
+ unbind_and_set(scene_layer->perspective.upper_right, knots[1]);
+ unbind_and_set(scene_layer->perspective.lower_right, knots[2]);
+ unbind_and_set(scene_layer->perspective.lower_left, knots[3]);
+ }