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

Side by Side Diff: src/image/SkImageShader.cpp

Issue 2197323002: implement isABitmap for imageshader, return localmatrix for bitmap's impl (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add isAImage api Created 4 years, 4 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 | « src/image/SkImageShader.h ('k') | src/image/SkImage_Base.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 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProvider.h" 9 #include "SkBitmapProvider.h"
10 #include "SkImage_Base.h" 10 #include "SkImage_Base.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 size_t SkImageShader::onContextSize(const ContextRec& rec) const { 45 size_t SkImageShader::onContextSize(const ContextRec& rec) const {
46 return SkBitmapProcShader::ContextSize(rec, SkBitmapProvider(fImage).info()) ; 46 return SkBitmapProcShader::ContextSize(rec, SkBitmapProvider(fImage).info()) ;
47 } 47 }
48 48
49 SkShader::Context* SkImageShader::onCreateContext(const ContextRec& rec, void* s torage) const { 49 SkShader::Context* SkImageShader::onCreateContext(const ContextRec& rec, void* s torage) const {
50 return SkBitmapProcShader::MakeContext(*this, fTileModeX, fTileModeY, 50 return SkBitmapProcShader::MakeContext(*this, fTileModeX, fTileModeY,
51 SkBitmapProvider(fImage), rec, storag e); 51 SkBitmapProvider(fImage), rec, storag e);
52 } 52 }
53 53
54 SkImage* SkImageShader::onIsAImage(SkMatrix* texM, TileMode xy[]) const {
55 if (texM) {
56 *texM = this->getLocalMatrix();
57 }
58 if (xy) {
59 xy[0] = (TileMode)fTileModeX;
60 xy[1] = (TileMode)fTileModeY;
61 }
62 return const_cast<SkImage*>(fImage.get());
63 }
64
65 bool SkImageShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[] ) const {
66 const SkBitmap* bm = as_IB(fImage)->onPeekBitmap();
67 if (!bm) {
68 return false;
69 }
70
71 if (texture) {
72 *texture = *bm;
73 }
74 if (texM) {
75 *texM = this->getLocalMatrix();
76 }
77 if (xy) {
78 xy[0] = (TileMode)fTileModeX;
79 xy[1] = (TileMode)fTileModeY;
80 }
81 return true;
82 }
83
54 sk_sp<SkShader> SkImageShader::Make(const SkImage* image, TileMode tx, TileMode ty, 84 sk_sp<SkShader> SkImageShader::Make(const SkImage* image, TileMode tx, TileMode ty,
55 const SkMatrix* localMatrix) { 85 const SkMatrix* localMatrix) {
56 if (!image) { 86 if (!image) {
57 return nullptr; 87 return nullptr;
58 } 88 }
59 return sk_sp<SkShader>(new SkImageShader(image, tx, ty, localMatrix)); 89 return sk_sp<SkShader>(new SkImageShader(image, tx, ty, localMatrix));
60 } 90 }
61 91
62 #ifndef SK_IGNORE_TO_STRING 92 #ifndef SK_IGNORE_TO_STRING
63 void SkImageShader::toString(SkString* str) const { 93 void SkImageShader::toString(SkString* str) const {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params); 154 inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params);
125 } 155 }
126 156
127 if (GrPixelConfigIsAlphaOnly(texture->config())) { 157 if (GrPixelConfigIsAlphaOnly(texture->config())) {
128 return inner; 158 return inner;
129 } 159 }
130 return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha (std::move(inner))); 160 return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha (std::move(inner)));
131 } 161 }
132 162
133 #endif 163 #endif
OLDNEW
« no previous file with comments | « src/image/SkImageShader.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698