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

Side by Side Diff: Source/platform/graphics/StaticBitmapPattern.cpp

Issue 785823002: use factory for colorshader, class is deprecated (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « Source/platform/graphics/Gradient.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/StaticBitmapPattern.h" 6 #include "platform/graphics/StaticBitmapPattern.h"
7 7
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/SkColorShader.h"
11 #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"
12 #include <v8.h> 12 #include <v8.h>
13 13
14 namespace blink { 14 namespace blink {
15 15
16 PassRefPtr<Pattern> StaticBitmapPattern::create(PassRefPtr<Image> tileImage, Rep eatMode repeatMode) 16 PassRefPtr<Pattern> StaticBitmapPattern::create(PassRefPtr<Image> tileImage, Rep eatMode repeatMode)
17 { 17 {
18 return adoptRef(new StaticBitmapPattern(tileImage->skImage(), repeatMode)); 18 return adoptRef(new StaticBitmapPattern(tileImage->skImage(), repeatMode));
19 } 19 }
20 20
21 StaticBitmapPattern::StaticBitmapPattern(PassRefPtr<SkImage> image, RepeatMode r epeatMode) 21 StaticBitmapPattern::StaticBitmapPattern(PassRefPtr<SkImage> image, RepeatMode r epeatMode)
22 : BitmapPatternBase(repeatMode, 0) 22 : BitmapPatternBase(repeatMode, 0)
23 { 23 {
24 if (image) { 24 if (image) {
25 m_tileImage = image; 25 m_tileImage = image;
26 adjustExternalMemoryAllocated(m_tileImage->width() * m_tileImage->height () * 4); 26 adjustExternalMemoryAllocated(m_tileImage->width() * m_tileImage->height () * 4);
27 } 27 }
28 } 28 }
29 29
30 StaticBitmapPattern::~StaticBitmapPattern() { } 30 StaticBitmapPattern::~StaticBitmapPattern() { }
31 31
32 PassRefPtr<SkShader> StaticBitmapPattern::createShader() 32 PassRefPtr<SkShader> StaticBitmapPattern::createShader()
33 { 33 {
34 // If we have no image, return null 34 // If we have no image, return null
35 if (!m_tileImage) { 35 if (!m_tileImage) {
36 return adoptRef(new SkColorShader(SK_ColorTRANSPARENT)); 36 return adoptRef(SkShader::CreateColorShader(SK_ColorTRANSPARENT));
37 } 37 }
38 38
39 SkMatrix localMatrix = affineTransformToSkMatrix(m_patternSpaceTransformatio n); 39 SkMatrix localMatrix = affineTransformToSkMatrix(m_patternSpaceTransformatio n);
40 40
41 if (isRepeatXY()) { 41 if (isRepeatXY()) {
42 return adoptRef(m_tileImage->newShader(SkShader::kRepeat_TileMode, SkSha der::kRepeat_TileMode, &localMatrix)); 42 return adoptRef(m_tileImage->newShader(SkShader::kRepeat_TileMode, SkSha der::kRepeat_TileMode, &localMatrix));
43 } 43 }
44 44
45 return BitmapPatternBase::createShader(); 45 return BitmapPatternBase::createShader();
46 } 46 }
47 47
48 SkImageInfo StaticBitmapPattern::getBitmapInfo() 48 SkImageInfo StaticBitmapPattern::getBitmapInfo()
49 { 49 {
50 return SkImageInfo::MakeN32Premul(m_tileImage->width(), m_tileImage->height( )); 50 return SkImageInfo::MakeN32Premul(m_tileImage->width(), m_tileImage->height( ));
51 } 51 }
52 52
53 void StaticBitmapPattern::drawBitmapToCanvas(SkCanvas& canvas, SkPaint& paint) 53 void StaticBitmapPattern::drawBitmapToCanvas(SkCanvas& canvas, SkPaint& paint)
54 { 54 {
55 canvas.drawImage(m_tileImage.get(), SkIntToScalar(0), SkIntToScalar(0), &pai nt); 55 canvas.drawImage(m_tileImage.get(), SkIntToScalar(0), SkIntToScalar(0), &pai nt);
56 } 56 }
57 57
58 } // namespace 58 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/graphics/Gradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698