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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImagePattern.cpp

Issue 2119623003: Do not clear canvas with transparent color after creating SkSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/platform/DragImage.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 "platform/graphics/ImagePattern.h" 5 #include "platform/graphics/ImagePattern.h"
6 6
7 #include "platform/graphics/Image.h" 7 #include "platform/graphics/Image.h"
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/SkImage.h" 10 #include "third_party/skia/include/core/SkImage.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 int expandH = isRepeatY() ? 0 : 1; 53 int expandH = isRepeatY() ? 0 : 1;
54 54
55 // Create a transparent image 1 pixel wider and/or taller than the 55 // Create a transparent image 1 pixel wider and/or taller than the
56 // original, then copy the orignal into it. 56 // original, then copy the orignal into it.
57 // FIXME: Is there a better way to pad (not scale) an image in skia? 57 // FIXME: Is there a better way to pad (not scale) an image in skia?
58 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( 58 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
59 m_tileImage->width() + expandW, m_tileImage->height() + expandH); 59 m_tileImage->width() + expandW, m_tileImage->height() + expandH);
60 if (!surface) 60 if (!surface)
61 return SkShader::MakeColorShader(SK_ColorTRANSPARENT); 61 return SkShader::MakeColorShader(SK_ColorTRANSPARENT);
62 62
63 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
64 SkPaint paint; 63 SkPaint paint;
65 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 64 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
66 surface->getCanvas()->drawImage(m_tileImage, 0, 0, &paint); 65 surface->getCanvas()->drawImage(m_tileImage, 0, 0, &paint);
67 66
68 return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &local Matrix); 67 return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &local Matrix);
69 } 68 }
70 69
71 bool ImagePattern::isTextureBacked() const 70 bool ImagePattern::isTextureBacked() const
72 { 71 {
73 return m_tileImage && m_tileImage->isTextureBacked(); 72 return m_tileImage && m_tileImage->isTextureBacked();
74 } 73 }
75 74
76 } // namespace blink 75 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/DragImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698