~townsend/compiz/fix-auto-vp-switch-0.9.10

« back to all changes in this revision

Viewing changes to plugins/imgpng/src/imgpng.h

img* plugins code cleanup:

Always bail out of function ASAP, do not calculate stuff you might not need.
Declare variables outside of loops so they won't be re-declared in each loop.
Use prefix instead of postfix increments.
Declaration and assignment of variables in one line.
Merged if condition checks.
Added and removed brackets.
Added and removed newlines, if appropriate.
Minor code structure improvements, declare variables when you need them, not
much earlier.
Fixed indentation.

Approved by PS Jenkins bot, Sam Spilsbury.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    public PluginClassHandler<PngScreen, CompScreen>
42
42
{
43
43
    public:
 
44
 
44
45
        PngScreen (CompScreen *screen);
45
46
        ~PngScreen ();
46
47
 
47
 
        bool fileToImage (CompString &path, CompSize &size,
48
 
                          int &stride, void *&data);
49
 
        bool imageToFile (CompString &path, CompString &format,
50
 
                          CompSize &size, int stride, void *data);
 
48
        bool fileToImage (CompString &path,
 
49
                          CompSize   &size,
 
50
                          int        &stride,
 
51
                          void       *&data);
 
52
 
 
53
        bool imageToFile (CompString &path,
 
54
                          CompString &format,
 
55
                          CompSize   &size,
 
56
                          int        stride,
 
57
                          void       *data);
51
58
 
52
59
    private:
 
60
 
53
61
        CompString fileNameWithExtension (CompString &path);
54
62
 
55
 
        bool readPngData (png_struct *png, png_info *info,
56
 
                          void *&data, CompSize &size);
57
 
        bool readPng (std::ifstream &file, CompSize &size, void *& data);
58
 
        bool writePng (unsigned char *buffer, std::ostream &file,
59
 
                       CompSize &size, int stride);
 
63
        bool readPngData (png_struct *png,
 
64
                          png_info   *info,
 
65
                          void       *&data,
 
66
                          CompSize   &size);
 
67
 
 
68
        bool readPng (std::ifstream &file,
 
69
                      CompSize      &size,
 
70
                      void          *&data);
 
71
 
 
72
        bool writePng (unsigned char *buffer,
 
73
                       std::ostream  &file,
 
74
                       CompSize      &size,
 
75
                       int           stride);
60
76
};
61
77
 
62
78
class PngPluginVTable :
63
79
    public CompPlugin::VTableForScreen<PngScreen>
64
80
{
65
81
    public:
 
82
 
66
83
        bool init ();
67
84
};
68
 
 
69
85
#endif