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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/skia/ImagePixelLocker.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/skia/ImagePixelLocker.h" 5 #include "platform/graphics/skia/ImagePixelLocker.h"
6 6
7 #include "third_party/skia/include/core/SkImage.h" 7 #include "third_party/skia/include/core/SkImage.h"
8 #include "third_party/skia/include/core/SkImageInfo.h" 8 #include "third_party/skia/include/core/SkImageInfo.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 namespace { 12 namespace {
13 13
14 bool infoIsCompatible(const SkImageInfo& info, SkAlphaType alphaType, SkColorTyp e colorType) 14 bool infoIsCompatible(const SkImageInfo& info, SkAlphaType alphaType, SkColorTyp e colorType)
15 { 15 {
16 ASSERT(alphaType != kUnknown_SkAlphaType); 16 ASSERT(alphaType != kUnknown_SkAlphaType);
17 17
18 if (info.colorType() != colorType) 18 if (info.colorType() != colorType)
19 return false; 19 return false;
20 20
21 // kOpaque_SkAlphaType works regardless of the requested alphaType. 21 // kOpaque_SkAlphaType works regardless of the requested alphaType.
22 return info.alphaType() == alphaType || info.alphaType() == kOpaque_SkAlphaT ype; 22 return info.alphaType() == alphaType || info.alphaType() == kOpaque_SkAlphaT ype;
23 } 23 }
24 24
25 } // anonymous namespace 25 } // anonymous namespace
26 26
27 ImagePixelLocker::ImagePixelLocker(PassRefPtr<const SkImage> image, SkAlphaType alphaType, 27 ImagePixelLocker::ImagePixelLocker(sk_sp<const SkImage> image, SkAlphaType alpha Type,
28 SkColorType colorType) 28 SkColorType colorType)
29 : m_image(image) 29 : m_image(std::move(image))
30 { 30 {
31 // If the image has in-RAM pixels and their format matches, use them directl y. 31 // If the image has in-RAM pixels and their format matches, use them directl y.
32 // TODO(fmalita): All current clients expect packed pixel rows. Maybe we co uld update them 32 // TODO(fmalita): All current clients expect packed pixel rows. Maybe we co uld update them
33 // to support arbitrary rowBytes, and relax the check below. 33 // to support arbitrary rowBytes, and relax the check below.
34 SkPixmap pixmap; 34 SkPixmap pixmap;
35 m_image->peekPixels(&pixmap); 35 m_image->peekPixels(&pixmap);
36 m_pixels = pixmap.addr(); 36 m_pixels = pixmap.addr();
37 if (m_pixels 37 if (m_pixels
38 && infoIsCompatible(pixmap.info(), alphaType, colorType) 38 && infoIsCompatible(pixmap.info(), alphaType, colorType)
39 && pixmap.rowBytes() == pixmap.info().minRowBytes()) { 39 && pixmap.rowBytes() == pixmap.info().minRowBytes()) {
(...skipping 12 matching lines...) Expand all
52 m_pixelStorage.reset(size); // this will throw on failure 52 m_pixelStorage.reset(size); // this will throw on failure
53 pixmap.reset(info, m_pixelStorage.get(), rowBytes); 53 pixmap.reset(info, m_pixelStorage.get(), rowBytes);
54 54
55 if (!m_image->readPixels(pixmap, 0, 0)) 55 if (!m_image->readPixels(pixmap, 0, 0))
56 return; 56 return;
57 57
58 m_pixels = m_pixelStorage.get(); 58 m_pixels = m_pixelStorage.get();
59 } 59 }
60 60
61 } // namespace blink 61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698