| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 this->getLocalMatrix()); | 187 this->getLocalMatrix()); |
| 188 | 188 |
| 189 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { | 189 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { |
| 190 SkBitmap bm; | 190 SkBitmap bm; |
| 191 bm.setInfo(SkImageInfo::MakeN32Premul(tileSize)); | 191 bm.setInfo(SkImageInfo::MakeN32Premul(tileSize)); |
| 192 if (!cache_try_alloc_pixels(&bm)) { | 192 if (!cache_try_alloc_pixels(&bm)) { |
| 193 return NULL; | 193 return NULL; |
| 194 } | 194 } |
| 195 bm.eraseColor(SK_ColorTRANSPARENT); | 195 bm.eraseColor(SK_ColorTRANSPARENT); |
| 196 | 196 |
| 197 SkCanvas canvas(bm); | 197 // Always disable LCD text, since we can't assume our image will be opaq
ue. |
| 198 SkCanvas canvas(bm, SkSurfaceProps(0, kUnknown_SkPixelGeometry)); |
| 199 |
| 198 canvas.scale(tileScale.width(), tileScale.height()); | 200 canvas.scale(tileScale.width(), tileScale.height()); |
| 199 canvas.translate(-fTile.x(), -fTile.y()); | 201 canvas.translate(-fTile.x(), -fTile.y()); |
| 200 canvas.drawPicture(fPicture); | 202 canvas.drawPicture(fPicture); |
| 201 | 203 |
| 202 SkMatrix shaderMatrix = this->getLocalMatrix(); | 204 SkMatrix shaderMatrix = this->getLocalMatrix(); |
| 203 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); | 205 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); |
| 204 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); | 206 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); |
| 205 | 207 |
| 206 SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(),
bm.getSize()))); | 208 SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(),
bm.getSize()))); |
| 207 } | 209 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC
olor, fp); | 307 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC
olor, fp); |
| 306 } | 308 } |
| 307 #else | 309 #else |
| 308 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, | 310 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, |
| 309 const SkMatrix*, GrColor*, | 311 const SkMatrix*, GrColor*, |
| 310 GrFragmentProcessor**) const { | 312 GrFragmentProcessor**) const { |
| 311 SkDEBUGFAIL("Should not call in GPU-less build"); | 313 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 312 return false; | 314 return false; |
| 313 } | 315 } |
| 314 #endif | 316 #endif |
| OLD | NEW |