| 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" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 int expandH = isRepeatY() ? 0 : 1; | 53 int expandH = isRepeatY() ? 0 : 1; |
| 54 | 54 |
| 55 // Create a transparent image 1 pixel wider and/or taller than the | 55 // Create a transparent image 1 pixel wider and/or taller than the |
| 56 // original, then copy the orignal into it. | 56 // original, then copy the orignal into it. |
| 57 // FIXME: Is there a better way to pad (not scale) an image in skia? | 57 // FIXME: Is there a better way to pad (not scale) an image in skia? |
| 58 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( | 58 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( |
| 59 m_tileImage->width() + expandW, m_tileImage->height() + expandH); | 59 m_tileImage->width() + expandW, m_tileImage->height() + expandH); |
| 60 if (!surface) | 60 if (!surface) |
| 61 return SkShader::MakeColorShader(SK_ColorTRANSPARENT); | 61 return SkShader::MakeColorShader(SK_ColorTRANSPARENT); |
| 62 | 62 |
| 63 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | |
| 64 SkPaint paint; | 63 SkPaint paint; |
| 65 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 64 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 66 surface->getCanvas()->drawImage(m_tileImage, 0, 0, &paint); | 65 surface->getCanvas()->drawImage(m_tileImage, 0, 0, &paint); |
| 67 | 66 |
| 68 return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &local
Matrix); | 67 return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &local
Matrix); |
| 69 } | 68 } |
| 70 | 69 |
| 71 bool ImagePattern::isTextureBacked() const | 70 bool ImagePattern::isTextureBacked() const |
| 72 { | 71 { |
| 73 return m_tileImage && m_tileImage->isTextureBacked(); | 72 return m_tileImage && m_tileImage->isTextureBacked(); |
| 74 } | 73 } |
| 75 | 74 |
| 76 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |