gfx/skia/trunk/src/core/SkBitmapProcShader.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 SkBitmapProcShader_DEFINED
    11 #define SkBitmapProcShader_DEFINED
    13 #include "SkShader.h"
    14 #include "SkBitmapProcState.h"
    15 #include "SkSmallAllocator.h"
    17 class SkBitmapProcShader : public SkShader {
    18 public:
    19     SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty);
    21     // overrides from SkShader
    22     virtual bool isOpaque() const SK_OVERRIDE;
    23     virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE;
    24     virtual void endContext() SK_OVERRIDE;
    25     virtual uint32_t getFlags() SK_OVERRIDE { return fFlags; }
    26     virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE;
    27     virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE;
    28     virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
    29     virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
    31     static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
    33     SK_TO_STRING_OVERRIDE()
    34     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
    36 #if SK_SUPPORT_GPU
    37     GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE;
    38 #endif
    40 protected:
    41     SkBitmapProcShader(SkReadBuffer& );
    42     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
    44     SkBitmap          fRawBitmap;   // experimental for RLE encoding
    45     SkBitmapProcState fState;
    46     uint32_t          fFlags;
    48 private:
    49     typedef SkShader INHERITED;
    50 };
    52 // Commonly used allocator. It currently is only used to allocate up to 2 objects. The total
    53 // bytes requested is calculated using one of our large shaders plus the size of an Sk3DBlitter
    54 // in SkDraw.cpp
    55 typedef SkSmallAllocator<2, sizeof(SkBitmapProcShader) + sizeof(void*) * 2> SkTBlitterAllocator;
    57 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and MUST outlive
    58 // the SkShader.
    59 SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::TileMode,
    60                              SkTBlitterAllocator* alloc);
    62 #endif

mercurial