Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2013 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef SkPaintPriv_DEFINED
      9 #define SkPaintPriv_DEFINED
     10 
     11 #include "SkTypes.h"
     12 
     13 class SkBitmap;
     14 class SkImage;
     15 class SkPaint;
     16 
     17 class SkPaintPriv {
     18 public:
     19     enum ShaderOverrideOpacity {
     20         kNone_ShaderOverrideOpacity,        //!< there is no overriding shader (bitmap or image)
     21         kOpaque_ShaderOverrideOpacity,      //!< the overriding shader is opaque
     22         kNotOpaque_ShaderOverrideOpacity,   //!< the overriding shader may not be opaque
     23     };
     24 
     25     /**
     26      *  Returns true if drawing with this paint (or nullptr) will ovewrite all affected pixels.
     27      *
     28      *  Note: returns conservative true, meaning it may return false even though the paint might
     29      *        in fact overwrite its pixels.
     30      */
     31     static bool Overwrites(const SkPaint* paint, ShaderOverrideOpacity);
     32 
     33     static bool Overwrites(const SkPaint& paint) {
     34         return Overwrites(&paint, kNone_ShaderOverrideOpacity);
     35     }
     36 
     37     /**
     38      *  Returns true if drawing this bitmap with this paint (or nullptr) will ovewrite all affected
     39      *  pixels.
     40      */
     41     static bool Overwrites(const SkBitmap&, const SkPaint* paint);
     42 
     43     /**
     44      *  Returns true if drawing this image with this paint (or nullptr) will ovewrite all affected
     45      *  pixels.
     46      */
     47     static bool Overwrites(const SkImage*, const SkPaint* paint);
     48 };
     49 
     50 #endif
     51