| 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 "config.h" | 5 #include "config.h" | 
| 6 #include "platform/graphics/ImagePattern.h" | 6 #include "platform/graphics/ImagePattern.h" | 
| 7 | 7 | 
|  | 8 #include "platform/graphics/BitmapImage.h" | 
|  | 9 #include "platform/graphics/GraphicsScreen.h" | 
| 8 #include "platform/graphics/Image.h" | 10 #include "platform/graphics/Image.h" | 
| 9 #include "platform/graphics/skia/SkiaUtils.h" | 11 #include "platform/graphics/skia/SkiaUtils.h" | 
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" | 
| 11 #include "third_party/skia/include/core/SkImage.h" | 13 #include "third_party/skia/include/core/SkImage.h" | 
| 12 #include "third_party/skia/include/core/SkShader.h" | 14 #include "third_party/skia/include/core/SkShader.h" | 
| 13 #include "third_party/skia/include/core/SkSurface.h" | 15 #include "third_party/skia/include/core/SkSurface.h" | 
| 14 | 16 | 
| 15 namespace blink { | 17 namespace blink { | 
| 16 | 18 | 
| 17 PassRefPtr<ImagePattern> ImagePattern::create(PassRefPtr<Image> image, RepeatMod
    e repeatMode) | 19 PassRefPtr<ImagePattern> ImagePattern::create(PassRefPtr<Image> image, RepeatMod
    e repeatMode) | 
| 18 { | 20 { | 
| 19     return adoptRef(new ImagePattern(image, repeatMode)); | 21     return adoptRef(new ImagePattern(image, repeatMode)); | 
| 20 } | 22 } | 
| 21 | 23 | 
| 22 ImagePattern::ImagePattern(PassRefPtr<Image> image, RepeatMode repeatMode) | 24 ImagePattern::ImagePattern(PassRefPtr<Image> image, RepeatMode repeatMode) | 
| 23     : Pattern(repeatMode) | 25     : Pattern(repeatMode) | 
| 24     , m_tileImage(image->imageForCurrentFrame()) |  | 
| 25 { | 26 { | 
|  | 27     // Patterns of tagged images (those that have a color profile) are drawn to 
    sRGB | 
|  | 28     // on supported platforms. Note the only allowed caller is the <canvas> elem
    ent. | 
|  | 29 | 
|  | 30     if (image && imageColorProfilesEnabled() && image->isBitmapImage()) { | 
|  | 31         if (toBitmapImage(image.get())->hasColorProfile()) | 
|  | 32             toBitmapImage(image.get())->notifyDeviceProfile(screenColorProfile(c
    urrentScreenId()).get()); | 
|  | 33         RELEASE_ASSERT(!currentScreenId()); // Check the caller is an HTML <canv
    as>. | 
|  | 34     } | 
|  | 35 | 
|  | 36     m_tileImage = image->imageForCurrentFrame(); | 
|  | 37 | 
| 26     if (m_tileImage) { | 38     if (m_tileImage) { | 
| 27         // TODO(fmalita): mechanism to extract the actual SkImageInfo from an Sk
    Image? | 39         // TODO(fmalita): mechanism to extract the actual SkImageInfo from an Sk
    Image? | 
| 28         const SkImageInfo info = | 40         const SkImageInfo info = | 
| 29             SkImageInfo::MakeN32Premul(m_tileImage->width(), m_tileImage->height
    ()); | 41             SkImageInfo::MakeN32Premul(m_tileImage->width(), m_tileImage->height
    ()); | 
| 30         adjustExternalMemoryAllocated(info.getSafeSize(info.minRowBytes())); | 42         adjustExternalMemoryAllocated(info.getSafeSize(info.minRowBytes())); | 
| 31     } | 43     } | 
| 32 } | 44 } | 
| 33 | 45 | 
| 34 PassRefPtr<SkShader> ImagePattern::createShader() | 46 PassRefPtr<SkShader> ImagePattern::createShader() | 
| 35 { | 47 { | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 72 | 84 | 
| 73     return adoptRef(expandedImage->newShader(tileModeX, tileModeY, &localMatrix)
    ); | 85     return adoptRef(expandedImage->newShader(tileModeX, tileModeY, &localMatrix)
    ); | 
| 74 } | 86 } | 
| 75 | 87 | 
| 76 bool ImagePattern::isTextureBacked() const | 88 bool ImagePattern::isTextureBacked() const | 
| 77 { | 89 { | 
| 78     return m_tileImage && m_tileImage->isTextureBacked(); | 90     return m_tileImage && m_tileImage->isTextureBacked(); | 
| 79 } | 91 } | 
| 80 | 92 | 
| 81 } // namespace | 93 } // namespace | 
| OLD | NEW | 
|---|