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

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: Make bitmapForCurrentFrame() return SkBitmap by value. 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
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 m_tileImage = image->bitmapForCurrentFrame();
20 20
21 if (m_tileImage) 21 if (!m_tileImage.isNull())
22 adjustExternalMemoryAllocated(m_tileImage->bitmap().getSafeSize()); 22 adjustExternalMemoryAllocated(m_tileImage.getSafeSize());
23 } 23 }
24 } 24 }
25 25
26 PassRefPtr<SkShader> BitmapPattern::createShader() 26 PassRefPtr<SkShader> BitmapPattern::createShader()
27 { 27 {
28 if (!m_tileImage) { 28 if (m_tileImage.isNull()) {
29 return adoptRef(SkShader::CreateColorShader(SK_ColorTRANSPARENT)); 29 return adoptRef(SkShader::CreateColorShader(SK_ColorTRANSPARENT));
30 } 30 }
31 31
32 SkMatrix localMatrix = affineTransformToSkMatrix(m_patternSpaceTransformatio n); 32 SkMatrix localMatrix = affineTransformToSkMatrix(m_patternSpaceTransformatio n);
33 33
34 if (isRepeatXY()) { 34 if (isRepeatXY()) {
35 return adoptRef(SkShader::CreateBitmapShader(m_tileImage->bitmap(), SkSh ader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMatrix)); 35 return adoptRef(SkShader::CreateBitmapShader(m_tileImage, SkShader::kRep eat_TileMode, SkShader::kRepeat_TileMode, &localMatrix));
36 } 36 }
37 37
38 return BitmapPatternBase::createShader(); 38 return BitmapPatternBase::createShader();
39 } 39 }
40 40
41 SkImageInfo BitmapPattern::getBitmapInfo() 41 SkImageInfo BitmapPattern::getBitmapInfo()
42 { 42 {
43 return m_tileImage->bitmap().info(); 43 return m_tileImage.info();
44 } 44 }
45 45
46 void BitmapPattern::drawBitmapToCanvas(SkCanvas& canvas, SkPaint& paint) 46 void BitmapPattern::drawBitmapToCanvas(SkCanvas& canvas, SkPaint& paint)
47 { 47 {
48 canvas.drawBitmap(m_tileImage->bitmap(), SkIntToScalar(0), SkIntToScalar(0), &paint); 48 canvas.drawBitmap(m_tileImage, SkIntToScalar(0), SkIntToScalar(0), &paint);
49 } 49 }
50 50
51 } // namespace 51 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698