Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: samplecode/SampleAnimator.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/utils/mac/SkCGUtils.h ('k') | src/animator/SkAnimateMaker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 SkAnimatorView::~SkAnimatorView() { 45 SkAnimatorView::~SkAnimatorView() {
46 delete fAnimator; 46 delete fAnimator;
47 } 47 }
48 48
49 void SkAnimatorView::setURIBase(const char dir[]) { 49 void SkAnimatorView::setURIBase(const char dir[]) {
50 fBaseURI.set(dir); 50 fBaseURI.set(dir);
51 } 51 }
52 52
53 bool SkAnimatorView::decodeFile(const char path[]) { 53 bool SkAnimatorView::decodeFile(const char path[]) {
54 SkFILEStream* is = new SkFILEStream(path); 54 SkAutoTDelete<SkStream> is(SkStream::NewFromFile(path));
55 SkAutoUnref aur(is); 55 return is.get() != NULL && this->decodeStream(is);
56 return is->isValid() && this->decodeStream(is);
57 } 56 }
58 57
59 bool SkAnimatorView::decodeMemory(const void* buffer, size_t size) { 58 bool SkAnimatorView::decodeMemory(const void* buffer, size_t size) {
60 SkMemoryStream* is = new SkMemoryStream(buffer, size); 59 SkMemoryStream is(buffer, size);
61 SkAutoUnref aur(is); 60 return this->decodeStream(&is);
62 return this->decodeStream(is);
63 } 61 }
64 62
65 static const SkDOMNode* find_nodeID(const SkDOM& dom, 63 static const SkDOMNode* find_nodeID(const SkDOM& dom,
66 const SkDOMNode* node, const char name[]) { 64 const SkDOMNode* node, const char name[]) {
67 if (NULL == node) { 65 if (NULL == node) {
68 node = dom.getRootNode(); 66 node = dom.getRootNode();
69 } 67 }
70 do { 68 do {
71 const char* idval = dom.findAttr(node, "id"); 69 const char* idval = dom.findAttr(node, "id");
72 if (idval && !strcmp(idval, name)) { 70 if (idval && !strcmp(idval, name)) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 av->setURIBase("/skia/trunk/animations/"); 163 av->setURIBase("/skia/trunk/animations/");
166 av->decodeFile("/skia/trunk/animations/checkbox.xml"); 164 av->decodeFile("/skia/trunk/animations/checkbox.xml");
167 #else 165 #else
168 av->setURIBase("/"); 166 av->setURIBase("/");
169 av->decodeFile("/testanim.txt"); 167 av->decodeFile("/testanim.txt");
170 #endif 168 #endif
171 return av; 169 return av;
172 } 170 }
173 171
174 static SkViewRegister reg(MyFactory); 172 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/utils/mac/SkCGUtils.h ('k') | src/animator/SkAnimateMaker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698