| 675 | } |
| 676 | |
| 677 | void Render::renderOnionskin( |
| 678 | Image* dstImage, |
| 679 | const gfx::Clip& area, |
| 680 | frame_t frame, Zoom zoom, |
| 681 | CompositeImageFunc compositeImage) |
| 682 | { |
| 683 | // Onion-skin feature: Draw previous/next frames with different |
| 684 | // opacity (<255) |
| 685 | if (m_onionskin.type() != OnionskinType::NONE) { |
| 686 | FrameTag* loop = m_onionskin.loopTag(); |
| 687 | Layer* onionLayer = (m_onionskin.layer() ? m_onionskin.layer(): |
| 688 | m_sprite->folder()); |
| 689 | frame_t frameIn; |
| 690 | |
| 691 | for (frame_t frameOut = frame - m_onionskin.prevFrames(); |
| 692 | frameOut <= frame + m_onionskin.nextFrames(); |
| 693 | ++frameOut) { |
| 694 | if (loop) { |
| 695 | bool pingPongForward = true; |
| 696 | frameIn = |
| 697 | calculate_next_frame(m_sprite, |
| 698 | frame, frameOut - frame, |
| 699 | loop, pingPongForward); |
| 700 | } |
| 701 | else { |
| 702 | frameIn = frameOut; |
| 703 | } |
| 704 | |
| 705 | if (frameIn == frame || |
| 706 | frameIn < 0 || |
| 707 | frameIn > m_sprite->lastFrame()) { |
| 708 | continue; |
| 709 | } |
| 710 | |
| 711 | if (frameOut < frame) { |
| 712 | m_globalOpacity = m_onionskin.opacityBase() - m_onionskin.opacityStep() * ((frame - frameOut)-1); |
| 713 | } |
| 714 | else { |
| 715 | m_globalOpacity = m_onionskin.opacityBase() - m_onionskin.opacityStep() * ((frameOut - frame)-1); |
| 716 | } |
| 717 | |
| 718 | m_globalOpacity = MID(0, m_globalOpacity, 255); |
| 719 | if (m_globalOpacity > 0) { |
| 720 | BlendMode blendMode = BlendMode::UNSPECIFIED; |
| 721 | if (m_onionskin.type() == OnionskinType::MERGE) |
| 722 | blendMode = BlendMode::NORMAL; |
| 723 | else if (m_onionskin.type() == OnionskinType::RED_BLUE_TINT) |
| 724 | blendMode = (frameOut < frame ? BlendMode::RED_TINT: BlendMode::BLUE_TINT); |
| 725 | |
| 726 | renderLayer( |
| 727 | onionLayer, dstImage, |
| 728 | area, frameIn, zoom, compositeImage, |
| 729 | // Render background only for "in-front" onion skinning and |
| 730 | // when opacity is < 255 |
| 731 | (m_globalOpacity < 255 && |
| 732 | m_onionskin.position() == OnionskinPosition::INFRONT), |
| 733 | true, |
| 734 | blendMode); |
nothing calls this directly
no test coverage detected