1 // Copyright (c) 2011 Hewlett-Packard Development Company, L.P. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef WEBVFX_EFFECTS_H_ 6 #define WEBVFX_EFFECTS_H_ 7 8 #include <webvfx/image.h> 9 #include <QMap> 10 #include <QString> 11 12 13 namespace WebVfx 14 { 15 16 /*! 17 * @brief An effects implementation that can consume video frame images and 18 * render output. 19 * 20 * Instances of this class are created with WebVfx::createEffects() 21 * and can be accessed from any thread, but the class is not threadsafe 22 * so access should be synchronized. 23 */ 24 class Effects 25 { 26 public: 27 /*! 28 * @brief Describes the type of an image. 29 */ 30 enum ImageType { 31 /*! 32 * The source (origin/from) image in a transition, 33 * or the image being processed in a filter. 34 */ 35 SourceImageType=1, 36 /*! 37 * The target (destination/to) image in a transition. 38 */ 39 TargetImageType, 40 /*! 41 * An extra image not directly participating in a 42 * filter or transition. 43 */ 44 ExtraImageType 45 }; 46 47 typedef QMap<QString, ImageType> ImageTypeMap; 48 typedef QMapIterator<QString, ImageType> ImageTypeMapIterator; 49 50 /*! 51 * @brief Describes the image names this effect will request. 52 * 53 * Images for these names will need to be set using setImage() 54 * each time before render() is called. 55 * @return a map mapping image names to their ImageType 56 */ 57 virtual const ImageTypeMap& getImageTypeMap() = 0; 58 59 /*! 60 * @brief Set an Image for the given @c name. 61 * 62 * @param name Name of the image 63 * @param image Image data. The Image pixels must remain valid until 64 * render() is called. 65 */ 66 virtual void setImage(const QString& name, Image* image) = 0; 67 68 /*! 69 * @brief Renders the effect for the given @c time. 70 * 71 * Prior to calling render() each time, all named images must 72 * be set via setImage(). 73 * @param time Time to render image for, must be from 0 to 1.0. 74 * @param renderImage Image buffer to render into. 75 */ 76 virtual bool render(double time, Image* renderImage) = 0; 77 78 /*! 79 * @brief Destroy the effect 80 */ 81 virtual void destroy() = 0; 82 83 /*! 84 * @brief Indicate that rendering is done. 85 * 86 * @param result This is the success/fail value to return from render(). 87 */ 88 virtual void renderComplete(bool result) = 0; 89 90 /*! 91 * @brief Reload the content. 92 */ 93 virtual void reload() = 0; 94 95 protected: Effects()96 Effects() {}; 97 virtual ~Effects() = 0; 98 }; 99 100 } 101 102 #endif 103