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

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

Issue 1001703003: Take NativeImageSkia out behind the woodshed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Switch to skia-style API (return bool instead of SkBitmap) Created 5 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/graphics/BitmapPattern.h ('k') | Source/platform/graphics/BitmapPatternBase.h » ('j') | 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/BitmapPattern.h" 6 #include "platform/graphics/BitmapPattern.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/SkShader.h" 10 #include "third_party/skia/include/core/SkShader.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 BitmapPattern::BitmapPattern(PassRefPtr<Image> image, RepeatMode repeatMode) 14 BitmapPattern::BitmapPattern(PassRefPtr<Image> image, RepeatMode repeatMode)
15 : BitmapPatternBase(repeatMode, 0 ) 15 : BitmapPatternBase(repeatMode, 0 )
16 { 16 {
17 if (image) { 17 if (image) {
18 // If image is animated, what about the pattern? 18 // If image is animated, what about the pattern?
19 m_tileImage = image->nativeImageForCurrentFrame(); 19 if (image->bitmapForCurrentFrame(&m_tileImage))
20 20 adjustExternalMemoryAllocated(m_tileImage.getSafeSize());
21 if (m_tileImage)
22 adjustExternalMemoryAllocated(m_tileImage->bitmap().getSafeSize());
23 } 21 }
24 } 22 }
25 23
26 PassRefPtr<SkShader> BitmapPattern::createShader() 24 PassRefPtr<SkShader> BitmapPattern::createShader()
27 { 25 {
28 if (!m_tileImage) { 26 if (m_tileImage.isNull()) {
29 return adoptRef(SkShader::CreateColorShader(SK_ColorTRANSPARENT)); 27 return adoptRef(SkShader::CreateColorShader(SK_ColorTRANSPARENT));
30 } 28 }
31 29
32 SkMatrix localMatrix = affineTransformToSkMatrix(m_patternSpaceTransformatio n); 30 SkMatrix localMatrix = affineTransformToSkMatrix(m_patternSpaceTransformatio n);
33 31
34 if (isRepeatXY()) { 32 if (isRepeatXY()) {
35 return adoptRef(SkShader::CreateBitmapShader(m_tileImage->bitmap(), SkSh ader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMatrix)); 33 return adoptRef(SkShader::CreateBitmapShader(m_tileImage, SkShader::kRep eat_TileMode, SkShader::kRepeat_TileMode, &localMatrix));
36 } 34 }
37 35
38 return BitmapPatternBase::createShader(); 36 return BitmapPatternBase::createShader();
39 } 37 }
40 38
41 SkImageInfo BitmapPattern::getBitmapInfo() 39 SkImageInfo BitmapPattern::getBitmapInfo()
42 { 40 {
43 return m_tileImage->bitmap().info(); 41 return m_tileImage.info();
44 } 42 }
45 43
46 void BitmapPattern::drawBitmapToCanvas(SkCanvas& canvas, SkPaint& paint) 44 void BitmapPattern::drawBitmapToCanvas(SkCanvas& canvas, SkPaint& paint)
47 { 45 {
48 canvas.drawBitmap(m_tileImage->bitmap(), SkIntToScalar(0), SkIntToScalar(0), &paint); 46 canvas.drawBitmap(m_tileImage, SkIntToScalar(0), SkIntToScalar(0), &paint);
49 } 47 }
50 48
51 } // namespace 49 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/graphics/BitmapPattern.h ('k') | Source/platform/graphics/BitmapPatternBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698