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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/views/SkWindow.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,119 @@
     1.4 +/*
     1.5 + * Copyright 2006 The Android Open Source Project
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkWindow_DEFINED
    1.12 +#define SkWindow_DEFINED
    1.13 +
    1.14 +#include "SkView.h"
    1.15 +#include "SkBitmap.h"
    1.16 +#include "SkMatrix.h"
    1.17 +#include "SkRegion.h"
    1.18 +#include "SkEvent.h"
    1.19 +#include "SkKey.h"
    1.20 +#include "SkTDArray.h"
    1.21 +
    1.22 +#ifdef SK_BUILD_FOR_WINCEx
    1.23 +    #define SHOW_FPS
    1.24 +#endif
    1.25 +//#define USE_GX_SCREEN
    1.26 +
    1.27 +class SkCanvas;
    1.28 +
    1.29 +class SkOSMenu;
    1.30 +
    1.31 +class SkWindow : public SkView {
    1.32 +public:
    1.33 +            SkWindow();
    1.34 +    virtual ~SkWindow();
    1.35 +
    1.36 +    const SkBitmap& getBitmap() const { return fBitmap; }
    1.37 +
    1.38 +    void    setColorType(SkColorType);
    1.39 +    void    resize(int width, int height, SkColorType = kUnknown_SkColorType);
    1.40 +
    1.41 +    bool    isDirty() const { return !fDirtyRgn.isEmpty(); }
    1.42 +    bool    update(SkIRect* updateArea);
    1.43 +    // does not call through to onHandleInval(), but does force the fDirtyRgn
    1.44 +    // to be wide open. Call before update() to ensure we redraw everything.
    1.45 +    void    forceInvalAll();
    1.46 +    // return the bounds of the dirty/inval rgn, or [0,0,0,0] if none
    1.47 +    const SkIRect& getDirtyBounds() const { return fDirtyRgn.getBounds(); }
    1.48 +
    1.49 +    bool    handleClick(int x, int y, Click::State, void* owner, unsigned modi = 0);
    1.50 +    bool    handleChar(SkUnichar);
    1.51 +    bool    handleKey(SkKey);
    1.52 +    bool    handleKeyUp(SkKey);
    1.53 +
    1.54 +    void    addMenu(SkOSMenu*);
    1.55 +    const SkTDArray<SkOSMenu*>* getMenus() { return &fMenus; }
    1.56 +
    1.57 +    const char* getTitle() const { return fTitle.c_str(); }
    1.58 +    void    setTitle(const char title[]);
    1.59 +
    1.60 +    const SkMatrix& getMatrix() const { return fMatrix; }
    1.61 +    void    setMatrix(const SkMatrix&);
    1.62 +    void    preConcat(const SkMatrix&);
    1.63 +    void    postConcat(const SkMatrix&);
    1.64 +
    1.65 +    virtual SkCanvas* createCanvas();
    1.66 +
    1.67 +    virtual void onPDFSaved(const char title[], const char desc[],
    1.68 +        const char path[]) {}
    1.69 +protected:
    1.70 +    virtual bool onEvent(const SkEvent&);
    1.71 +    virtual bool onDispatchClick(int x, int y, Click::State, void* owner, unsigned modi);
    1.72 +    // called if part of our bitmap is invalidated
    1.73 +    virtual void onHandleInval(const SkIRect&);
    1.74 +    virtual bool onHandleChar(SkUnichar);
    1.75 +    virtual bool onHandleKey(SkKey);
    1.76 +    virtual bool onHandleKeyUp(SkKey);
    1.77 +    virtual void onAddMenu(const SkOSMenu*) {};
    1.78 +    virtual void onUpdateMenu(const SkOSMenu*) {};
    1.79 +    virtual void onSetTitle(const char title[]) {}
    1.80 +
    1.81 +    // overrides from SkView
    1.82 +    virtual bool handleInval(const SkRect*);
    1.83 +    virtual bool onGetFocusView(SkView** focus) const;
    1.84 +    virtual bool onSetFocusView(SkView* focus);
    1.85 +
    1.86 +private:
    1.87 +    SkColorType fColorType;
    1.88 +    SkBitmap    fBitmap;
    1.89 +    SkRegion    fDirtyRgn;
    1.90 +
    1.91 +    SkTDArray<Click*>       fClicks; // to track clicks
    1.92 +
    1.93 +    SkTDArray<SkOSMenu*>    fMenus;
    1.94 +
    1.95 +    SkView* fFocusView;
    1.96 +    bool    fWaitingOnInval;
    1.97 +
    1.98 +    SkString    fTitle;
    1.99 +    SkMatrix    fMatrix;
   1.100 +
   1.101 +    typedef SkView INHERITED;
   1.102 +};
   1.103 +
   1.104 +////////////////////////////////////////////////////////////////////////////////
   1.105 +
   1.106 +#if defined(SK_BUILD_FOR_NACL)
   1.107 +    #include "SkOSWindow_NaCl.h"
   1.108 +#elif defined(SK_BUILD_FOR_MAC)
   1.109 +    #include "SkOSWindow_Mac.h"
   1.110 +#elif defined(SK_BUILD_FOR_WIN)
   1.111 +    #include "SkOSWindow_Win.h"
   1.112 +#elif defined(SK_BUILD_FOR_ANDROID)
   1.113 +    #include "SkOSWindow_Android.h"
   1.114 +#elif defined(SK_BUILD_FOR_UNIX)
   1.115 +  #include "SkOSWindow_Unix.h"
   1.116 +#elif defined(SK_BUILD_FOR_SDL)
   1.117 +    #include "SkOSWindow_SDL.h"
   1.118 +#elif defined(SK_BUILD_FOR_IOS)
   1.119 +    #include "SkOSWindow_iOS.h"
   1.120 +#endif
   1.121 +
   1.122 +#endif

mercurial