author Mike Hommey <>
Tue, 26 Mar 2019 16:29:17 +0000
changeset 466239 12b301ea0f924424f0a5057f1ebccc7cd8098e8e
parent 448947 6f3709b3878117466168c40affa7bca0b60cf75b
child 475915 524f61bca4383cae06562409c789cb26d5865c06
permissions -rw-r--r--
Bug 1537641 - Make MIDL use clang-cl as a preprocessor. r=dmajor Using clang-cl as a preprocessor fails with: ``` In file included from z:\build\build\src\accessible\ipc\win\handler\HandlerData.idl:8: z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(27,8): error: pasting formed 'Accessible2_3.', an invalid preprocessing token [-Winvalid-token-paste] import NEWEST_IA2_IDL; ^ z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(15,24): note: expanded from macro 'NEWEST_IA2_IDL' ^ z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(14,22): note: expanded from macro 'IDLFOR' ^ z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(13,36): note: expanded from macro '__GENIDL' ^ 1 error generated. midl : command line error MIDL1003 : error returned by the C preprocessor (1) ``` There's only one place using the NEWEST_IA2_IDL and accompanying macros, we can just avoid the issue altogether by expanding it manually (and it's not like the macro buys much, the other arm of the __midl ifdef has a #include "Accessible2_3.h" that doesn't use the macro either, presumably for the same reason). Differential Revision:

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_image_decoders_nsWebPDecoder_h
#define mozilla_image_decoders_nsWebPDecoder_h

#include "Decoder.h"
#include "webp/demux.h"
#include "StreamingLexer.h"
#include "SurfacePipe.h"

namespace mozilla {
namespace image {
class RasterImage;

class nsWebPDecoder final : public Decoder {
  virtual ~nsWebPDecoder();

  DecoderType GetType() const override { return DecoderType::WEBP; }

  LexerResult DoDecode(SourceBufferIterator& aIterator,
                       IResumable* aOnResume) override;
  Maybe<Telemetry::HistogramID> SpeedHistogram() const override;

  friend class DecoderFactory;

  // Decoders should only be instantiated via DecoderFactory.
  explicit nsWebPDecoder(RasterImage* aImage);

  void ApplyColorProfile(const char* aProfile, size_t aLength);

  LexerResult UpdateBuffer(SourceBufferIterator& aIterator,
                           SourceBufferIterator::State aState);
  LexerResult ReadData();
  LexerResult ReadHeader(WebPDemuxer* aDemuxer, bool aIsComplete);
  LexerResult ReadPayload(WebPDemuxer* aDemuxer, bool aIsComplete);

  nsresult CreateFrame(const nsIntRect& aFrameRect);
  void EndFrame();

  LexerResult ReadSingle(const uint8_t* aData, size_t aLength,
                         const IntRect& aFrameRect);

  LexerResult ReadMultiple(WebPDemuxer* aDemuxer, bool aIsComplete);

  /// The SurfacePipe used to write to the output surface.
  SurfacePipe mPipe;

  /// The buffer used to accumulate data until the complete WebP header is
  /// received, if and only if the iterator is discontiguous.
  Vector<uint8_t> mBufferedData;

  /// The libwebp output buffer descriptor pointing to the decoded data.
  WebPDecBuffer mBuffer;

  /// The libwebp incremental decoder descriptor, wraps mBuffer.
  WebPIDecoder* mDecoder;

  /// Blend method for the current frame.
  BlendMethod mBlend;

  /// Disposal method for the current frame.
  DisposalMethod mDisposal;

  /// Frame timeout for the current frame;
  FrameTimeout mTimeout;

  /// Surface format for the current frame.
  gfx::SurfaceFormat mFormat;

  /// Frame rect for the current frame.
  IntRect mFrameRect;

  /// The last row of decoded pixels written to mPipe.
  int mLastRow;

  /// Number of decoded frames.
  uint32_t mCurrentFrame;

  /// Pointer to the start of the contiguous encoded image data.
  const uint8_t* mData;

  /// Length of data pointed to by mData.
  size_t mLength;

  /// True if the iterator has reached its end.
  bool mIteratorComplete;

  /// True if this decoding pass requires a WebPDemuxer.
  bool mNeedDemuxer;

  /// True if we have setup the color profile for the image.
  bool mGotColorProfile;

  /// Color management profile from the ICCP chunk in the image.
  qcms_profile* mInProfile;

  /// Color management transform to apply to image data.
  qcms_transform* mTransform;

}  // namespace image
}  // namespace mozilla

#endif  // mozilla_image_decoders_nsWebPDecoder_h