gfx/skia/trunk/include/views/SkWindow.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /*
     2  * Copyright 2006 The Android Open Source Project
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef SkWindow_DEFINED
     9 #define SkWindow_DEFINED
    11 #include "SkView.h"
    12 #include "SkBitmap.h"
    13 #include "SkMatrix.h"
    14 #include "SkRegion.h"
    15 #include "SkEvent.h"
    16 #include "SkKey.h"
    17 #include "SkTDArray.h"
    19 #ifdef SK_BUILD_FOR_WINCEx
    20     #define SHOW_FPS
    21 #endif
    22 //#define USE_GX_SCREEN
    24 class SkCanvas;
    26 class SkOSMenu;
    28 class SkWindow : public SkView {
    29 public:
    30             SkWindow();
    31     virtual ~SkWindow();
    33     const SkBitmap& getBitmap() const { return fBitmap; }
    35     void    setColorType(SkColorType);
    36     void    resize(int width, int height, SkColorType = kUnknown_SkColorType);
    38     bool    isDirty() const { return !fDirtyRgn.isEmpty(); }
    39     bool    update(SkIRect* updateArea);
    40     // does not call through to onHandleInval(), but does force the fDirtyRgn
    41     // to be wide open. Call before update() to ensure we redraw everything.
    42     void    forceInvalAll();
    43     // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none
    44     const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); }
    46     bool    handleClick(int x, int y, Click::State, void* owner, unsigned modi = 0);
    47     bool    handleChar(SkUnichar);
    48     bool    handleKey(SkKey);
    49     bool    handleKeyUp(SkKey);
    51     void    addMenu(SkOSMenu*);
    52     const SkTDArray<SkOSMenu*>* getMenus() { return &fMenus; }
    54     const char* getTitle() const { return fTitle.c_str(); }
    55     void    setTitle(const char title[]);
    57     const SkMatrix& getMatrix() const { return fMatrix; }
    58     void    setMatrix(const SkMatrix&);
    59     void    preConcat(const SkMatrix&);
    60     void    postConcat(const SkMatrix&);
    62     virtual SkCanvas* createCanvas();
    64     virtual void onPDFSaved(const char title[], const char desc[],
    65         const char path[]) {}
    66 protected:
    67     virtual bool onEvent(const SkEvent&);
    68     virtual bool onDispatchClick(int x, int y, Click::State, void* owner, unsigned modi);
    69     // called if part of our bitmap is invalidated
    70     virtual void onHandleInval(const SkIRect&);
    71     virtual bool onHandleChar(SkUnichar);
    72     virtual bool onHandleKey(SkKey);
    73     virtual bool onHandleKeyUp(SkKey);
    74     virtual void onAddMenu(const SkOSMenu*) {};
    75     virtual void onUpdateMenu(const SkOSMenu*) {};
    76     virtual void onSetTitle(const char title[]) {}
    78     // overrides from SkView
    79     virtual bool handleInval(const SkRect*);
    80     virtual bool onGetFocusView(SkView** focus) const;
    81     virtual bool onSetFocusView(SkView* focus);
    83 private:
    84     SkColorType fColorType;
    85     SkBitmap    fBitmap;
    86     SkRegion    fDirtyRgn;
    88     SkTDArray<Click*>       fClicks; // to track clicks
    90     SkTDArray<SkOSMenu*>    fMenus;
    92     SkView* fFocusView;
    93     bool    fWaitingOnInval;
    95     SkString    fTitle;
    96     SkMatrix    fMatrix;
    98     typedef SkView INHERITED;
    99 };
   101 ////////////////////////////////////////////////////////////////////////////////
   103 #if defined(SK_BUILD_FOR_NACL)
   104     #include "SkOSWindow_NaCl.h"
   105 #elif defined(SK_BUILD_FOR_MAC)
   106     #include "SkOSWindow_Mac.h"
   107 #elif defined(SK_BUILD_FOR_WIN)
   108     #include "SkOSWindow_Win.h"
   109 #elif defined(SK_BUILD_FOR_ANDROID)
   110     #include "SkOSWindow_Android.h"
   111 #elif defined(SK_BUILD_FOR_UNIX)
   112   #include "SkOSWindow_Unix.h"
   113 #elif defined(SK_BUILD_FOR_SDL)
   114     #include "SkOSWindow_SDL.h"
   115 #elif defined(SK_BUILD_FOR_IOS)
   116     #include "SkOSWindow_iOS.h"
   117 #endif
   119 #endif

mercurial