2
// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
#ifndef GNASH_BITMAPMOVIEDEFINITION_H
19
#define GNASH_BITMAPMOVIEDEFINITION_H
21
#include "movie_definition.h" // for inheritance
22
#include "rect.h" // for composition
23
#include "BitmapMovieInstance.h" // for create_movie_instance
24
#include "bitmap_character_def.h" // for destructor visibility by intrusive_ptr
25
#include "DynamicShape.h" // for destructor visibility by intrusive_ptr
28
#include <memory> // for auto_ptr
30
// Forward declarations
32
class bitmap_character_def;
38
/// A "movie" definition for a bitmap file
40
/// The create_movie_instance function will return a BitmapMovieInstance
42
class BitmapMovieDefinition : public movie_definition
50
std::auto_ptr<image::rgb> _image;
52
boost::intrusive_ptr<bitmap_character_def> _bitmap;
54
boost::intrusive_ptr<DynamicShape> _shapedef;
56
/// Get the shape character definition for this bitmap movie
58
/// It will create the definition the first time it's called
60
shape_character_def* getShapeDef();
67
/// Mark reachable resources of a BitmapMovieDefinition
69
/// Reachable resources are:
70
/// - dynamic shape (_shapedef)
71
/// - bitmap (_bitmap)
73
void markReachableResources() const;
74
#endif // GNASH_USE_GC
79
/// Construct a BitmapMovieDefinition for the given image (rgb)
81
/// Will be initialized with the following values
84
/// - Framesize extracted from image
85
/// - Single frame (unlabeled)
87
/// - image->size() bytes (for get_bytes_loaded()/get_bytes_total())
90
BitmapMovieDefinition(std::auto_ptr<image::rgb> image, const std::string& url);
92
// Discard id, always return the only shape character we have
93
virtual character_def* get_character_def(int /*id*/)
98
virtual int get_version() const {
102
virtual float get_width_pixels() const {
103
return ceilf(TWIPS_TO_PIXELS(_framesize.width()));
106
virtual float get_height_pixels() const {
107
return ceilf(TWIPS_TO_PIXELS(_framesize.height()));
110
virtual size_t get_frame_count() const {
114
virtual float get_frame_rate() const {
118
virtual const rect& get_frame_size() const {
122
virtual const rect& get_bound() const {
126
/// Return number of bytes loaded
128
/// Since no progressive load is implemented yet
129
/// we'll always return total bytes here..
131
virtual size_t get_bytes_loaded() const {
132
return get_bytes_total();
135
/// Return total number of bytes which composed this movie
137
/// We actually cheat, and return the image size here...
139
virtual size_t get_bytes_total() const {
143
/// Create a playable movie_instance from this def.
144
virtual movie_instance* create_movie_instance(character* parent=0)
146
return new BitmapMovieInstance(this, parent);
149
virtual const std::string& get_url() const {
153
// Inheritance from movie_definition requires this.
154
// we always return 1 so sprite_instance::stagePlacementCallback
155
// doesn't skip our handling (TODO: check if it's correct to
156
// skip handling of 0-frames movies..).
157
size_t get_loading_frame() const
165
#endif // GNASH_BITMAPMOVIEDEFINITION_H