OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkPictureShader.h" | 8 #include "SkPictureShader.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { | 178 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { |
179 SkBitmap bm; | 179 SkBitmap bm; |
180 bm.setInfo(SkImageInfo::MakeN32Premul(tileSize)); | 180 bm.setInfo(SkImageInfo::MakeN32Premul(tileSize)); |
181 if (!cache_try_alloc_pixels(&bm)) { | 181 if (!cache_try_alloc_pixels(&bm)) { |
182 return NULL; | 182 return NULL; |
183 } | 183 } |
184 bm.eraseColor(SK_ColorTRANSPARENT); | 184 bm.eraseColor(SK_ColorTRANSPARENT); |
185 | 185 |
186 SkCanvas canvas(bm); | 186 SkCanvas canvas(bm); |
187 canvas.scale(tileScale.width(), tileScale.height()); | 187 canvas.scale(tileScale.width(), tileScale.height()); |
188 canvas.translate(fTile.x(), fTile.y()); | 188 canvas.translate(-fTile.x(), -fTile.y()); |
189 canvas.drawPicture(fPicture); | 189 canvas.drawPicture(fPicture); |
190 | 190 |
191 SkMatrix shaderMatrix = this->getLocalMatrix(); | 191 SkMatrix shaderMatrix = this->getLocalMatrix(); |
192 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); | 192 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); |
193 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); | 193 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); |
194 | 194 |
195 SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(),
bm.getSize()))); | 195 SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(),
bm.getSize()))); |
196 } | 196 } |
197 | 197 |
198 return tileShader.detach(); | 198 return tileShader.detach(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, f
p); | 289 return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, f
p); |
290 } | 290 } |
291 #else | 291 #else |
292 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix*, GrColor*, | 292 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix*, GrColor*, |
293 GrFragmentProcessor**) const { | 293 GrFragmentProcessor**) const { |
294 SkDEBUGFAIL("Should not call in GPU-less build"); | 294 SkDEBUGFAIL("Should not call in GPU-less build"); |
295 return false; | 295 return false; |
296 } | 296 } |
297 #endif | 297 #endif |
OLD | NEW |