gfx/skia/trunk/src/pdf/SkPDFShader.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     2 /*
     3  * Copyright 2011 Google Inc.
     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 SkPDFShader_DEFINED
    11 #define SkPDFShader_DEFINED
    13 #include "SkPDFStream.h"
    14 #include "SkPDFTypes.h"
    15 #include "SkMatrix.h"
    16 #include "SkRefCnt.h"
    17 #include "SkShader.h"
    19 class SkObjRef;
    20 class SkPDFCatalog;
    22 /** \class SkPDFShader
    24     In PDF parlance, this is a pattern, used in place of a color when the
    25     pattern color space is selected.
    26 */
    28 class SkPDFShader {
    29 public:
    30     /** Get the PDF shader for the passed SkShader. If the SkShader is
    31      *  invalid in some way, returns NULL. The reference count of
    32      *  the object is incremented and it is the caller's responsibility to
    33      *  unreference it when done.  This is needed to accommodate the weak
    34      *  reference pattern used when the returned object is new and has no
    35      *  other references.
    36      *  @param shader     The SkShader to emulate.
    37      *  @param matrix     The current transform. (PDF shaders are absolutely
    38      *                    positioned, relative to where the page is drawn.)
    39      *  @param surfceBBox The bounding box of the drawing surface (with matrix
    40      *                    already applied).
    41      */
    42     static SkPDFObject* GetPDFShader(const SkShader& shader,
    43                                      const SkMatrix& matrix,
    44                                      const SkIRect& surfaceBBox);
    46 protected:
    47     class State;
    49     class ShaderCanonicalEntry {
    50     public:
    51         ShaderCanonicalEntry(SkPDFObject* pdfShader, const State* state);
    52         bool operator==(const ShaderCanonicalEntry& b) const;
    54         SkPDFObject* fPDFShader;
    55         const State* fState;
    56     };
    57     // This should be made a hash table if performance is a problem.
    58     static SkTDArray<ShaderCanonicalEntry>& CanonicalShaders();
    59     static SkBaseMutex& CanonicalShadersMutex();
    61     // This is an internal method.
    62     // CanonicalShadersMutex() should already be acquired.
    63     // This also takes ownership of shaderState.
    64     static SkPDFObject* GetPDFShaderByState(State* shaderState);
    65     static void RemoveShader(SkPDFObject* shader);
    67     SkPDFShader();
    68     virtual ~SkPDFShader() {};
    70     virtual bool isValid() = 0;
    71 };
    73 #endif

mercurial