gfx/skia/trunk/include/core/SkFlattenable.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.

     2 /*
     3  * Copyright 2006 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #ifndef SkFlattenable_DEFINED
    11 #define SkFlattenable_DEFINED
    13 #include "SkRefCnt.h"
    15 class SkReadBuffer;
    16 class SkWriteBuffer;
    18 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
    19         SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
    20                                  flattenable::GetFlattenableType());
    22 #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables();
    24 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \
    25     void flattenable::InitializeFlattenables() {
    27 #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
    28     }
    30 #define SK_DECLARE_UNFLATTENABLE_OBJECT() \
    31     virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
    33 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
    34     virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \
    35     static SkFlattenable* CreateProc(SkReadBuffer& buffer) { \
    36         return SkNEW_ARGS(flattenable, (buffer)); \
    37     }
    39 /** For SkFlattenable derived objects with a valid type
    40     This macro should only be used in base class objects in core
    41   */
    42 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \
    43     static Type GetFlattenableType() { \
    44         return k##flattenable##_Type; \
    45     }
    47 /** \class SkFlattenable
    49  SkFlattenable is the base class for objects that need to be flattened
    50  into a data stream for either transport or as part of the key to the
    51  font cache.
    52  */
    53 class SK_API SkFlattenable : public SkRefCnt {
    54 public:
    55     enum Type {
    56         kSkColorFilter_Type,
    57         kSkDrawLooper_Type,
    58         kSkImageFilter_Type,
    59         kSkMaskFilter_Type,
    60         kSkPathEffect_Type,
    61         kSkPixelRef_Type,
    62         kSkRasterizer_Type,
    63         kSkShader_Type,
    64         kSkUnitMapper_Type,
    65         kSkXfermode_Type,
    66     };
    68     SK_DECLARE_INST_COUNT(SkFlattenable)
    70     typedef SkFlattenable* (*Factory)(SkReadBuffer&);
    72     SkFlattenable() {}
    74     /** Implement this to return a factory function pointer that can be called
    75      to recreate your class given a buffer (previously written to by your
    76      override of flatten().
    77      */
    78     virtual Factory getFactory() const = 0;
    80     /** Returns the name of the object's class
    81       */
    82     const char* getTypeName() const { return FactoryToName(getFactory()); }
    84     static Factory NameToFactory(const char name[]);
    85     static const char* FactoryToName(Factory);
    86     static bool NameToType(const char name[], Type* type);
    88     static void Register(const char name[], Factory, Type);
    90     class Registrar {
    91     public:
    92         Registrar(const char name[], Factory factory, Type type) {
    93             SkFlattenable::Register(name, factory, type);
    94         }
    95     };
    97     /** Override this to write data specific to your subclass into the buffer,
    98      being sure to call your super-class' version first. This data will later
    99      be passed to your Factory function, returned by getFactory().
   100      */
   101     virtual void flatten(SkWriteBuffer&) const;
   103 protected:
   104     SkFlattenable(SkReadBuffer&) {}
   106 private:
   107     static void InitializeFlattenablesIfNeeded();
   109     friend class SkGraphics;
   111     typedef SkRefCnt INHERITED;
   112 };
   114 #endif

mercurial