gfx/skia/trunk/include/core/SkBounder.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 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 SkBounder_DEFINED
    11 #define SkBounder_DEFINED
    13 #include "SkTypes.h"
    14 #include "SkRefCnt.h"
    15 #include "SkPoint.h"
    17 struct SkGlyph;
    18 struct SkIRect;
    19 struct SkPoint;
    20 struct SkRect;
    21 class SkPaint;
    22 class SkPath;
    23 class SkRegion;
    25 /** \class SkBounder
    27     Base class for intercepting the device bounds of shapes before they are drawn.
    28     Install a subclass of this in your canvas.
    29 */
    30 class SkBounder : public SkRefCnt {
    31 public:
    32     SK_DECLARE_INST_COUNT(SkBounder)
    34     SkBounder();
    36     /* Call to perform a clip test before calling onIRect.
    37        Returns the result from onIRect.
    38     */
    39     bool doIRect(const SkIRect&);
    40     bool doIRectGlyph(const SkIRect& , int x, int y, const SkGlyph&);
    42 protected:
    43     /** Override in your subclass. This is called with the device bounds of an
    44         object (text, geometry, image) just before it is drawn. If your method
    45         returns false, the drawing for that shape is aborted. If your method
    46         returns true, drawing continues. The bounds your method receives have already
    47         been transformed in to device coordinates, and clipped to the current clip.
    48     */
    49     virtual bool onIRect(const SkIRect&) {
    50         return false;
    51     }
    53     /** Passed to onIRectGlyph with the information about the current glyph.
    54         LSB and RSB are fixed-point (16.16) coordinates of the start and end
    55         of the glyph's advance
    56      */
    57     struct GlyphRec {
    58         SkIPoint    fLSB;   //!< fixed-point left-side-bearing of the glyph
    59         SkIPoint    fRSB;   //!< fixed-point right-side-bearing of the glyph
    60         uint16_t    fGlyphID;
    61         uint16_t    fFlags; //!< currently set to 0
    62     };
    64     /** Optionally, override in your subclass to receive the glyph ID when
    65         text drawing supplies the device bounds of the object.
    66     */
    67     virtual bool onIRectGlyph(const SkIRect& r, const GlyphRec&) {
    68         return onIRect(r);
    69     }
    71     /** Called after each shape has been drawn. The default implementation does
    72         nothing, but your override could use this notification to signal itself
    73         that the offscreen being rendered into needs to be updated to the screen.
    74     */
    75     virtual void commit();
    77 private:
    78     bool doHairline(const SkPoint&, const SkPoint&, const SkPaint&);
    79     bool doRect(const SkRect&, const SkPaint&);
    80     bool doPath(const SkPath&, const SkPaint&, bool doFill);
    81     void setClip(const SkRegion* clip) { fClip = clip; }
    83     const SkRegion* fClip;
    84     friend class SkAutoBounderCommit;
    85     friend class SkDraw;
    86     friend class SkDrawIter;
    87     friend struct Draw1Glyph;
    88     friend class SkMaskFilter;
    90     typedef SkRefCnt INHERITED;
    91 };
    93 #endif

mercurial