blob: f8461937c665f4b34b3b8555fe4267e56e50ea59 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/* libs/graphics/animator/SkDrawBitmap.h
2**
3** Copyright 2006, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef SkDrawBitmap_DEFINED
19#define SkDrawBitmap_DEFINED
20
21#include "SkBoundable.h"
22#include "SkBase64.h"
23#include "SkBitmap.h"
24// #include "SkImageDecoder.h"
25#include "SkMemberInfo.h"
26
27class SkBaseBitmap : public SkBoundable {
28 DECLARE_MEMBER_INFO(BaseBitmap);
29 SkBaseBitmap();
30 virtual ~SkBaseBitmap();
31 virtual bool draw(SkAnimateMaker& );
32protected:
33 SkBitmap fBitmap;
34 SkScalar x;
35 SkScalar y;
36private:
37 friend class SkDrawTo;
38 friend class SkDrawBitmapShader;
39 typedef SkBoundable INHERITED;
40};
41
42class SkDrawBitmap : public SkBaseBitmap {
43 DECLARE_DRAW_MEMBER_INFO(Bitmap);
44 SkDrawBitmap();
45 virtual ~SkDrawBitmap();
46#ifdef SK_DUMP_ENABLED
47 virtual void dump(SkAnimateMaker* );
48#endif
49 virtual void onEndElement(SkAnimateMaker& );
50 virtual bool setProperty(int index, SkScriptValue& value);
51protected:
52 int /*SkBitmap::Config*/ format;
53 int32_t height;
54 int32_t rowBytes;
55 int32_t width;
56 SkColor fColor;
57 SkBool fColorSet;
58 typedef SkBaseBitmap INHERITED;
59};
60
61class SkImage : public SkBaseBitmap {
62 DECLARE_MEMBER_INFO(Image);
63 SkImage();
64 virtual ~SkImage();
65 virtual SkDisplayable* deepCopy(SkAnimateMaker* );
66 virtual void dirty();
67 virtual bool draw(SkAnimateMaker& );
68 virtual bool getProperty(int index, SkScriptValue* value) const;
69 virtual void onEndElement(SkAnimateMaker& maker);
70private:
71 void resolve() const { (const_cast<SkImage*>(this))->resolve(); }
72 void resolve();
73protected:
74 SkBase64 base64;
75 SkString src;
76 SkString fLast; // cache of src so that stream isn't unnecessarily decoded
77 SkBool fDirty;
78 const char* fUriBase;
79 typedef SkBaseBitmap INHERITED;
80};
81
82#endif // SkDrawBitmap_DEFINED