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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Wide enough to display all the frames. | 91 // Wide enough to display all the frames. |
92 dim.fWidth *= fTotalFrames; | 92 dim.fWidth *= fTotalFrames; |
93 // Tall enough to show the row of frames plus an animating version. | 93 // Tall enough to show the row of frames plus an animating version. |
94 dim.fHeight *= 2; | 94 dim.fHeight *= 2; |
95 return dim; | 95 return dim; |
96 } | 96 } |
97 return SkISize::Make(640, 480); | 97 return SkISize::Make(640, 480); |
98 } | 98 } |
99 | 99 |
100 void onDrawBackground(SkCanvas* canvas) override { | 100 void onDrawBackground(SkCanvas* canvas) override { |
| 101 canvas->clear(SK_ColorWHITE); |
101 if (this->initCodec()) { | 102 if (this->initCodec()) { |
102 SkAutoCanvasRestore acr(canvas, true); | 103 SkAutoCanvasRestore acr(canvas, true); |
103 for (size_t frameIndex = 0; frameIndex < fTotalFrames; frameIndex++)
{ | 104 for (size_t frameIndex = 0; frameIndex < fTotalFrames; frameIndex++)
{ |
104 this->drawFrame(canvas, frameIndex); | 105 this->drawFrame(canvas, frameIndex); |
105 canvas->translate(fCodec->getInfo().width(), 0); | 106 canvas->translate(fCodec->getInfo().width(), 0); |
106 } | 107 } |
107 } | 108 } |
108 } | 109 } |
109 | 110 |
110 bool initCodec() { | 111 bool initCodec() { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // in order to draw correctly. | 177 // in order to draw correctly. |
177 fNextUpdate += fFrameInfos[fFrame].fDuration; | 178 fNextUpdate += fFrameInfos[fFrame].fDuration; |
178 } | 179 } |
179 | 180 |
180 return true; | 181 return true; |
181 } | 182 } |
182 }; | 183 }; |
183 | 184 |
184 DEF_GM(return new AnimatedGifGM); | 185 DEF_GM(return new AnimatedGifGM); |
185 | 186 |
OLD | NEW |