| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 | 124 |
| 125 fCodec.reset(SkCodec::NewFromStream(stream.release())); | 125 fCodec.reset(SkCodec::NewFromStream(stream.release())); |
| 126 if (!fCodec) { | 126 if (!fCodec) { |
| 127 SkDebugf("Could create codec from %s", FLAGS_animatedGif[0]); | 127 SkDebugf("Could create codec from %s", FLAGS_animatedGif[0]); |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 | 130 |
| 131 fFrame = 0; | 131 fFrame = 0; |
| 132 fFrameInfos = fCodec->getFrameInfo(); | 132 if (!fCodec->getFrameInfo(&fFrameInfos, nullptr)) { |
| 133 SkDebugf("%s is not animated", FLAGS_animatedGif[0]); |
| 134 return false; |
| 135 } |
| 133 fTotalFrames = fFrameInfos.size(); | 136 fTotalFrames = fFrameInfos.size(); |
| 134 return true; | 137 return true; |
| 135 } | 138 } |
| 136 | 139 |
| 137 void onDraw(SkCanvas* canvas) override { | 140 void onDraw(SkCanvas* canvas) override { |
| 138 if (!fCodec) { | 141 if (!fCodec) { |
| 139 SkString errorText = SkStringPrintf("Nothing to draw; %s", FLAGS_ani
matedGif[0]); | 142 SkString errorText = SkStringPrintf("Nothing to draw; %s", FLAGS_ani
matedGif[0]); |
| 140 error(canvas, errorText); | 143 error(canvas, errorText); |
| 141 return; | 144 return; |
| 142 } | 145 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // in order to draw correctly. | 180 // in order to draw correctly. |
| 178 fNextUpdate += fFrameInfos[fFrame].fDuration; | 181 fNextUpdate += fFrameInfos[fFrame].fDuration; |
| 179 } | 182 } |
| 180 | 183 |
| 181 return true; | 184 return true; |
| 182 } | 185 } |
| 183 }; | 186 }; |
| 184 | 187 |
| 185 DEF_GM(return new AnimatedGifGM); | 188 DEF_GM(return new AnimatedGifGM); |
| 186 | 189 |
| OLD | NEW |