1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/views/animated/SkImageView.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkImageView_DEFINED 1.14 +#define SkImageView_DEFINED 1.15 + 1.16 +#include "SkView.h" 1.17 +#include "SkString.h" 1.18 + 1.19 +class SkAnimator; 1.20 +class SkBitmap; 1.21 +class SkMatrix; 1.22 + 1.23 +class SkImageView : public SkView { 1.24 +public: 1.25 + SkImageView(); 1.26 + virtual ~SkImageView(); 1.27 + 1.28 + void getUri(SkString*) const; 1.29 + void setUri(const char []); 1.30 + void setUri(const SkString&); 1.31 + 1.32 + 1.33 + enum ScaleType { 1.34 + kMatrix_ScaleType, 1.35 + kFitXY_ScaleType, 1.36 + kFitStart_ScaleType, 1.37 + kFitCenter_ScaleType, 1.38 + kFitEnd_ScaleType 1.39 + }; 1.40 + ScaleType getScaleType() const { return (ScaleType)fScaleType; } 1.41 + void setScaleType(ScaleType); 1.42 + 1.43 + bool getImageMatrix(SkMatrix*) const; 1.44 + void setImageMatrix(const SkMatrix*); 1.45 + 1.46 +protected: 1.47 + // overrides 1.48 + virtual bool onEvent(const SkEvent&); 1.49 + virtual void onDraw(SkCanvas*); 1.50 + virtual void onInflate(const SkDOM&, const SkDOMNode*); 1.51 + 1.52 +private: 1.53 + SkString fUri; 1.54 + SkMatrix* fMatrix; // null or copy of caller's matrix ,,,,, 1.55 + union { 1.56 + SkAnimator* fAnim; 1.57 + SkBitmap* fBitmap; 1.58 + } fData; 1.59 + uint8_t fScaleType; 1.60 + SkBool8 fDataIsAnim; // as opposed to bitmap 1.61 + SkBool8 fUriIsValid; 1.62 + 1.63 + void onUriChange(); 1.64 + bool getDataBounds(SkRect* bounds); 1.65 + bool freeData(); 1.66 + bool ensureUriIsLoaded(); 1.67 + 1.68 + typedef SkView INHERITED; 1.69 +}; 1.70 + 1.71 +#endif