gfx/layers/ImageDataSerializer.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=8 et :
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #ifndef GFX_LAYERS_BLOBSURFACE_H
     9 #define GFX_LAYERS_BLOBSURFACE_H
    11 #include <stdint.h>                     // for uint8_t, uint32_t
    12 #include "mozilla/Attributes.h"         // for MOZ_STACK_CLASS
    13 #include "mozilla/RefPtr.h"             // for TemporaryRef
    14 #include "mozilla/gfx/Point.h"          // for IntSize
    15 #include "mozilla/gfx/Types.h"          // for SurfaceFormat
    17 class gfxImageSurface;
    19 namespace mozilla {
    20 namespace gfx {
    21 class DataSourceSurface;
    22 class DrawTarget;
    23 } // namespace gfx
    24 } // namespace mozilla
    26 namespace mozilla {
    27 namespace layers {
    29 class ImageDataSerializerBase
    30 {
    31 public:
    32   bool IsValid() const { return mIsValid; }
    34   uint8_t* GetData();
    35   uint32_t GetStride() const;
    36   gfx::IntSize GetSize() const;
    37   gfx::SurfaceFormat GetFormat() const;
    38   TemporaryRef<gfx::DataSourceSurface> GetAsSurface();
    39   TemporaryRef<gfxImageSurface> GetAsThebesSurface();
    40   TemporaryRef<gfx::DrawTarget> GetAsDrawTarget(gfx::BackendType aBackend);
    42   static uint32_t ComputeMinBufferSize(gfx::IntSize aSize,
    43                                        gfx::SurfaceFormat aFormat);
    45 protected:
    47   ImageDataSerializerBase(uint8_t* aData, size_t aDataSize)
    48     : mData(aData)
    49     , mDataSize(aDataSize)
    50     , mIsValid(false)
    51   {}
    53   void Validate();
    55   uint8_t* mData;
    56   size_t mDataSize;
    57   bool mIsValid;
    58 };
    60 /**
    61  * A facility to serialize an image into a buffer of memory.
    62  * This is intended for use with the IPC code, in order to copy image data
    63  * into shared memory.
    64  * Note that there is a separate serializer class for YCbCr images
    65  * (see YCbCrImageDataSerializer.h).
    66  */
    67 class MOZ_STACK_CLASS ImageDataSerializer : public ImageDataSerializerBase
    68 {
    69 public:
    70   ImageDataSerializer(uint8_t* aData, size_t aDataSize)
    71     : ImageDataSerializerBase(aData, aDataSize)
    72   {
    73     // a serializer needs to be usable before correct buffer info has been written to it
    74     mIsValid = !!mData;
    75   }
    76   void InitializeBufferInfo(gfx::IntSize aSize,
    77                             gfx::SurfaceFormat aFormat);
    78 };
    80 /**
    81  * A facility to deserialize image data that has been serialized by an
    82  * ImageDataSerializer.
    83  */
    84 class MOZ_STACK_CLASS ImageDataDeserializer : public ImageDataSerializerBase
    85 {
    86 public:
    87   ImageDataDeserializer(uint8_t* aData, size_t aDataSize)
    88     : ImageDataSerializerBase(aData, aDataSize)
    89   {
    90     Validate();
    91   }
    93 };
    95 } // namespace layers
    96 } // namespace mozilla
    98 #endif

mercurial