OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 #include "SkView.h" | 8 #include "SkView.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 | 10 |
11 #include "SkAnimator.h" | 11 #include "SkAnimator.h" |
12 #include "SkStream.h" | 12 #include "SkStream.h" |
13 #include "SkDOM.h" | 13 #include "SkDOM.h" |
14 | 14 |
| 15 #include <memory> |
| 16 |
15 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
16 | 18 |
17 class SkAnimatorView : public SkView { | 19 class SkAnimatorView : public SkView { |
18 public: | 20 public: |
19 SkAnimatorView(); | 21 SkAnimatorView(); |
20 virtual ~SkAnimatorView(); | 22 virtual ~SkAnimatorView(); |
21 | 23 |
22 void setURIBase(const char dir[]); | 24 void setURIBase(const char dir[]); |
23 | 25 |
24 SkAnimator* getAnimator() const { return fAnimator; } | 26 SkAnimator* getAnimator() const { return fAnimator; } |
(...skipping 18 matching lines...) Expand all Loading... |
43 | 45 |
44 SkAnimatorView::~SkAnimatorView() { | 46 SkAnimatorView::~SkAnimatorView() { |
45 delete fAnimator; | 47 delete fAnimator; |
46 } | 48 } |
47 | 49 |
48 void SkAnimatorView::setURIBase(const char dir[]) { | 50 void SkAnimatorView::setURIBase(const char dir[]) { |
49 fBaseURI.set(dir); | 51 fBaseURI.set(dir); |
50 } | 52 } |
51 | 53 |
52 bool SkAnimatorView::decodeFile(const char path[]) { | 54 bool SkAnimatorView::decodeFile(const char path[]) { |
53 SkAutoTDelete<SkStream> is(SkStream::NewFromFile(path)); | 55 std::unique_ptr<SkStream> is = SkStream::MakeFromFile(path); |
54 return is.get() != nullptr && this->decodeStream(is); | 56 return is && this->decodeStream(is.get()); |
55 } | 57 } |
56 | 58 |
57 bool SkAnimatorView::decodeMemory(const void* buffer, size_t size) { | 59 bool SkAnimatorView::decodeMemory(const void* buffer, size_t size) { |
58 SkMemoryStream is(buffer, size); | 60 SkMemoryStream is(buffer, size); |
59 return this->decodeStream(&is); | 61 return this->decodeStream(&is); |
60 } | 62 } |
61 | 63 |
62 static const SkDOMNode* find_nodeID(const SkDOM& dom, | 64 static const SkDOMNode* find_nodeID(const SkDOM& dom, |
63 const SkDOMNode* node, const char name[]) { | 65 const SkDOMNode* node, const char name[]) { |
64 if (nullptr == node) { | 66 if (nullptr == node) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 av->setURIBase("/skia/trunk/animations/"); | 164 av->setURIBase("/skia/trunk/animations/"); |
163 av->decodeFile("/skia/trunk/animations/checkbox.xml"); | 165 av->decodeFile("/skia/trunk/animations/checkbox.xml"); |
164 #else | 166 #else |
165 av->setURIBase("/"); | 167 av->setURIBase("/"); |
166 av->decodeFile("/testanim.txt"); | 168 av->decodeFile("/testanim.txt"); |
167 #endif | 169 #endif |
168 return av; | 170 return av; |
169 } | 171 } |
170 | 172 |
171 static SkViewRegister reg(MyFactory); | 173 static SkViewRegister reg(MyFactory); |
OLD | NEW |