Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ImagePattern.h" | 5 #include "platform/graphics/ImagePattern.h" |
| 6 | 6 |
| 7 #include "platform/graphics/Image.h" | 7 #include "platform/graphics/Image.h" |
| 8 #include "platform/graphics/skia/SkiaUtils.h" | 8 #include "platform/graphics/skia/SkiaUtils.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "third_party/skia/include/core/SkImage.h" | 10 #include "third_party/skia/include/core/SkImage.h" |
| 11 #include "third_party/skia/include/core/SkShader.h" | 11 #include "third_party/skia/include/core/SkShader.h" |
| 12 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 PassRefPtr<ImagePattern> ImagePattern::create(PassRefPtr<Image> image, RepeatMod e repeatMode) | 16 PassRefPtr<ImagePattern> ImagePattern::create(PassRefPtr<Image> image, RepeatMod e repeatMode) |
| 17 { | 17 { |
| 18 return adoptRef(new ImagePattern(std::move(image), repeatMode)); | 18 return adoptRef(new ImagePattern(std::move(image), repeatMode)); |
|
Justin Novosad
2016/09/14 18:07:45
Perhaps add a null check here?
| |
| 19 } | 19 } |
| 20 | 20 |
| 21 ImagePattern::ImagePattern(PassRefPtr<Image> image, RepeatMode repeatMode) | 21 ImagePattern::ImagePattern(PassRefPtr<Image> image, RepeatMode repeatMode) |
| 22 : Pattern(repeatMode) | 22 : Pattern(repeatMode) |
| 23 , m_tileImage(image->imageForCurrentFrame()) | 23 , m_tileImage(image->imageForCurrentFrame()) |
| 24 { | 24 { |
| 25 m_previousLocalMatrix.setIdentity(); | 25 SkMatrix matrix; |
| 26 matrix.setIdentity(); | |
|
Justin Novosad
2016/09/14 18:05:08
I don't understand what this is supposed to fix. T
| |
| 27 m_previousLocalMatrix = matrix; | |
| 26 if (m_tileImage) { | 28 if (m_tileImage) { |
| 27 // TODO(fmalita): mechanism to extract the actual SkImageInfo from an Sk Image? | 29 // TODO(fmalita): mechanism to extract the actual SkImageInfo from an Sk Image? |
| 28 const SkImageInfo info = SkImageInfo::MakeN32Premul( | 30 const SkImageInfo info = SkImageInfo::MakeN32Premul( |
| 29 m_tileImage->width() + (isRepeatX() ? 0 : 2), | 31 m_tileImage->width() + (isRepeatX() ? 0 : 2), |
| 30 m_tileImage->height() + (isRepeatY() ? 0 : 2)); | 32 m_tileImage->height() + (isRepeatY() ? 0 : 2)); |
| 31 adjustExternalMemoryAllocated(info.getSafeSize(info.minRowBytes())); | 33 adjustExternalMemoryAllocated(info.getSafeSize(info.minRowBytes())); |
| 32 } | 34 } |
| 33 } | 35 } |
| 34 | 36 |
| 35 bool ImagePattern::isLocalMatrixChanged(const SkMatrix& localMatrix) const | 37 bool ImagePattern::isLocalMatrixChanged(const SkMatrix& localMatrix) const |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 | 81 |
| 80 return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &adjus tedMatrix); | 82 return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &adjus tedMatrix); |
| 81 } | 83 } |
| 82 | 84 |
| 83 bool ImagePattern::isTextureBacked() const | 85 bool ImagePattern::isTextureBacked() const |
| 84 { | 86 { |
| 85 return m_tileImage && m_tileImage->isTextureBacked(); | 87 return m_tileImage && m_tileImage->isTextureBacked(); |
| 86 } | 88 } |
| 87 | 89 |
| 88 } // namespace blink | 90 } // namespace blink |
| OLD | NEW |