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
3 // found in the LICENSE file.
6 #include "platform/graphics/PicturePattern.h"
8 #include "platform/graphics/skia/SkiaUtils.h"
9 #include "third_party/skia/include/core/SkPicture.h"
10 #include "third_party/skia/include/core/SkShader.h"
14 PassRefPtr
<PicturePattern
> PicturePattern::create(PassRefPtr
<const SkPicture
> picture
,
15 RepeatMode repeatMode
)
17 return adoptRef(new PicturePattern(picture
, repeatMode
));
20 PicturePattern::PicturePattern(PassRefPtr
<const SkPicture
> picture
, RepeatMode mode
)
22 , m_tilePicture(picture
)
24 // All current clients use RepeatModeXY, so we only support this mode for now.
27 // FIXME: we don't have a good way to account for DL memory utilization.
30 PicturePattern::~PicturePattern()
34 PassRefPtr
<SkShader
> PicturePattern::createShader()
36 SkMatrix localMatrix
= affineTransformToSkMatrix(m_patternSpaceTransformation
);
37 SkRect tileBounds
= m_tilePicture
->cullRect();
39 return adoptRef(SkShader::CreatePictureShader(m_tilePicture
.get(),
40 SkShader::kRepeat_TileMode
, SkShader::kRepeat_TileMode
, &localMatrix
, &tileBounds
));