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

Side by Side Diff: tools/viewer/ImageSlide.cpp

Issue 2056343004: Add samples to Viewer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add samples.gypi Created 4 years, 6 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 | « tools/viewer/ImageSlide.h ('k') | tools/viewer/SKPSlide.h » ('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 * 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 "ImageSlide.h" 8 #include "ImageSlide.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 17 matching lines...) Expand all
28 if (canvas->getMetaData().hasBool(kImageColorXformMetaData, true)) { 28 if (canvas->getMetaData().hasBool(kImageColorXformMetaData, true)) {
29 canvas->drawBitmap(fXformedBitmap, 0, 0); 29 canvas->drawBitmap(fXformedBitmap, 0, 0);
30 } else { 30 } else {
31 // skbug.com/5428 31 // skbug.com/5428
32 // drawImage() and drawBitmap() behave differently in sRGB mode. 32 // drawImage() and drawBitmap() behave differently in sRGB mode.
33 // canvas->drawImage(fImage.get(), 0, 0); 33 // canvas->drawImage(fImage.get(), 0, 0);
34 canvas->drawBitmap(fOriginalBitmap, 0, 0); 34 canvas->drawBitmap(fOriginalBitmap, 0, 0);
35 } 35 }
36 } 36 }
37 37
38 void ImageSlide::load() { 38 void ImageSlide::load(SkScalar, SkScalar) {
39 sk_sp<SkData> encoded = SkData::MakeFromFileName(fPath.c_str()); 39 sk_sp<SkData> encoded = SkData::MakeFromFileName(fPath.c_str());
40 fImage = SkImage::MakeFromEncoded(encoded); 40 fImage = SkImage::MakeFromEncoded(encoded);
41 fImage->asLegacyBitmap(&fOriginalBitmap, SkImage::kRO_LegacyBitmapMode); 41 fImage->asLegacyBitmap(&fOriginalBitmap, SkImage::kRO_LegacyBitmapMode);
42 42
43 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded.get())); 43 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded.get()));
44 sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getColorSpace()); 44 sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getColorSpace());
45 sk_sp<SkColorSpace> dstSpace = SkColorSpace::NewNamed(SkColorSpace::kAdobeRG B_Named); 45 sk_sp<SkColorSpace> dstSpace = SkColorSpace::NewNamed(SkColorSpace::kAdobeRG B_Named);
46 std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace, dstSpace); 46 std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace, dstSpace);
47 fOriginalBitmap.deepCopyTo(&fXformedBitmap); 47 fOriginalBitmap.deepCopyTo(&fXformedBitmap);
48 uint32_t* row = (uint32_t*) fXformedBitmap.getPixels(); 48 uint32_t* row = (uint32_t*) fXformedBitmap.getPixels();
49 for (int y = 0; y < fXformedBitmap.height(); y++) { 49 for (int y = 0; y < fXformedBitmap.height(); y++) {
50 xform->xform_RGBA_8888(row, row, fXformedBitmap.width()); 50 xform->xform_RGBA_8888(row, row, fXformedBitmap.width());
51 row = SkTAddOffset<uint32_t>(row, fXformedBitmap.rowBytes()); 51 row = SkTAddOffset<uint32_t>(row, fXformedBitmap.rowBytes());
52 } 52 }
53 fXformedBitmap.notifyPixelsChanged(); // This is needed for the deepCopy 53 fXformedBitmap.notifyPixelsChanged(); // This is needed for the deepCopy
54 } 54 }
55 55
56 void ImageSlide::unload() { 56 void ImageSlide::unload() {
57 fImage.reset(nullptr); 57 fImage.reset(nullptr);
58 } 58 }
OLDNEW
« no previous file with comments | « tools/viewer/ImageSlide.h ('k') | tools/viewer/SKPSlide.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698