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

Side by Side Diff: src/codec/SkBmpRLECodec.cpp

Issue 1689983002: Avoid initializing memory twice on incomplete RLE bmps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkBmpRLECodec.h" 8 #include "SkBmpRLECodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 496
497 private: 497 private:
498 int onSetSampleX(int sampleX) override { 498 int onSetSampleX(int sampleX) override {
499 return fCodec->setSampleX(sampleX); 499 return fCodec->setSampleX(sampleX);
500 } 500 }
501 501
502 // Unowned pointer. fCodec will delete this class in its destructor. 502 // Unowned pointer. fCodec will delete this class in its destructor.
503 SkBmpRLECodec* fCodec; 503 SkBmpRLECodec* fCodec;
504 }; 504 };
505 505
506 SkSampler* SkBmpRLECodec::getSampler(bool createIfNecessary) { 506 SkSampler* SkBmpRLECodec::getSampler(bool /*createIfNecessary*/) {
507 if (!fSampler && createIfNecessary) { 507 // We will always create an SkBmpRLESampler if one is requested.
508 // This allows clients to always use the SkBmpRLESampler's
509 // version of fill(), which does nothing since RLE decodes have
510 // already filled pixel memory. This seems fine, since creating
511 // an SkBmpRLESampler is pretty inexpensive.
512 if (!fSampler) {
508 fSampler.reset(new SkBmpRLESampler(this)); 513 fSampler.reset(new SkBmpRLESampler(this));
509 } 514 }
510 515
511 return fSampler; 516 return fSampler;
512 } 517 }
513 518
514 int SkBmpRLECodec::setSampleX(int sampleX){ 519 int SkBmpRLECodec::setSampleX(int sampleX){
515 fSampleX = sampleX; 520 fSampleX = sampleX;
516 return get_scaled_dimension(this->getInfo().width(), sampleX); 521 return get_scaled_dimension(this->getInfo().width(), sampleX);
517 } 522 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698