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

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

Issue 2391943002: Rewrap comments to 80 columns in platform/graphics/{compositing,cpu,gpu,skia}/. (Closed)
Patch Set: One space Created 4 years, 2 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 {
(...skipping 13 matching lines...) Expand all
24 info.alphaType() == kOpaque_SkAlphaType; 24 info.alphaType() == kOpaque_SkAlphaType;
25 } 25 }
26 26
27 } // anonymous namespace 27 } // anonymous namespace
28 28
29 ImagePixelLocker::ImagePixelLocker(sk_sp<const SkImage> image, 29 ImagePixelLocker::ImagePixelLocker(sk_sp<const SkImage> image,
30 SkAlphaType alphaType, 30 SkAlphaType alphaType,
31 SkColorType colorType) 31 SkColorType colorType)
32 : m_image(std::move(image)) { 32 : m_image(std::move(image)) {
33 // If the image has in-RAM pixels and their format matches, use them directly. 33 // If the image has in-RAM pixels and their format matches, use them directly.
34 // TODO(fmalita): All current clients expect packed pixel rows. Maybe we coul d update them 34 // TODO(fmalita): All current clients expect packed pixel rows. Maybe we
35 // to support arbitrary rowBytes, and relax the check below. 35 // could update them to support arbitrary rowBytes, and relax the check below.
36 SkPixmap pixmap; 36 SkPixmap pixmap;
37 m_image->peekPixels(&pixmap); 37 m_image->peekPixels(&pixmap);
38 m_pixels = pixmap.addr(); 38 m_pixels = pixmap.addr();
39 if (m_pixels && infoIsCompatible(pixmap.info(), alphaType, colorType) && 39 if (m_pixels && infoIsCompatible(pixmap.info(), alphaType, colorType) &&
40 pixmap.rowBytes() == pixmap.info().minRowBytes()) { 40 pixmap.rowBytes() == pixmap.info().minRowBytes()) {
41 return; 41 return;
42 } 42 }
43 43
44 m_pixels = nullptr; 44 m_pixels = nullptr;
45 45
46 // No luck, we need to read the pixels into our local buffer. 46 // No luck, we need to read the pixels into our local buffer.
47 SkImageInfo info = SkImageInfo::Make(m_image->width(), m_image->height(), 47 SkImageInfo info = SkImageInfo::Make(m_image->width(), m_image->height(),
48 colorType, alphaType); 48 colorType, alphaType);
49 size_t rowBytes = info.minRowBytes(); 49 size_t rowBytes = info.minRowBytes();
50 size_t size = info.getSafeSize(rowBytes); 50 size_t size = info.getSafeSize(rowBytes);
51 if (0 == size) 51 if (0 == size)
52 return; 52 return;
53 53
54 m_pixelStorage.reset(size); // this will throw on failure 54 m_pixelStorage.reset(size); // this will throw on failure
55 pixmap.reset(info, m_pixelStorage.get(), rowBytes); 55 pixmap.reset(info, m_pixelStorage.get(), rowBytes);
56 56
57 if (!m_image->readPixels(pixmap, 0, 0)) 57 if (!m_image->readPixels(pixmap, 0, 0))
58 return; 58 return;
59 59
60 m_pixels = m_pixelStorage.get(); 60 m_pixels = m_pixelStorage.get();
61 } 61 }
62 62
63 } // namespace blink 63 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698