/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkWebpEncoder_DEFINED
#define SkWebpEncoder_DEFINED

#include "SkEncoder.h"

class SkWStream;

namespace SK_API SkWebpEncoder {

    struct Options {
        /**
         *  |fQuality| must be in [0.0f, 100.0f] where 0.0f corresponds to the lowest quality.
         */
        float fQuality = 100.0f;

        /**
         *  If the input is premultiplied, this controls the unpremultiplication behavior.
         *  The encoder can convert to linear before unpremultiplying or ignore the transfer
         *  function and unpremultiply the input as is.
         */
        SkTransferFunctionBehavior fUnpremulBehavior = SkTransferFunctionBehavior::kRespect;
    };

    /**
     *  Encode the |src| pixels to the |dst| stream.
     *  |options| may be used to control the encoding behavior.
     *
     *  Returns true on success.  Returns false on an invalid or unsupported |src|.
     */
    bool Encode(SkWStream* dst, const SkPixmap& src, const Options& options);
};

#endif

/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkWebpEncoder_DEFINED
#define SkWebpEncoder_DEFINED

#include "SkEncoder.h"

class SkWStream;

namespace SkWebpEncoder {

    struct SK_API Options {
        /**
         *  |fQuality| must be in [0.0f, 100.0f] where 0.0f corresponds to the lowest quality.
         */
        float fQuality = 100.0f;

        /**
         *  If the input is premultiplied, this controls the unpremultiplication behavior.
         *  The encoder can convert to linear before unpremultiplying or ignore the transfer
         *  function and unpremultiply the input as is.
         */
        SkTransferFunctionBehavior fUnpremulBehavior = SkTransferFunctionBehavior::kRespect;
    };

    /**
     *  Encode the |src| pixels to the |dst| stream.
     *  |options| may be used to control the encoding behavior.
     *
     *  Returns true on success.  Returns false on an invalid or unsupported |src|.
     */
    SK_API bool Encode(SkWStream* dst, const SkPixmap& src, const Options& options);
};

#endif

Move SK_API from namespace to function
Move SK_API from namespace to function

Bug: skia:
Change-Id: Ib538b77c28e323bbcc40634b0f3cd87d88d898e8
Reviewed-on: https://skia-review.googlesource.com/16496
Reviewed-by: Mike Reed <f5cabf8735907151a446812c9875d6c0c712d847@google.com>
Reviewed-by: Matt Sarett <bb43c9b8214fcf1292f134c9714ba8a0e7075913@google.com>
Commit-Queue: Matt Sarett <bb43c9b8214fcf1292f134c9714ba8a0e7075913@google.com>
