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

Side by Side Diff: src/pdf/SkPDFShader.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/SkImage_Raster.cpp ('k') | tests/ShaderTest.cpp » ('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 2011 Google Inc. 2 * Copyright 2011 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 8
9 #include "SkPDFShader.h" 9 #include "SkPDFShader.h"
10 10
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 fBBox(bbox) { 1282 fBBox(bbox) {
1283 fInfo.fColorCount = 0; 1283 fInfo.fColorCount = 0;
1284 fInfo.fColors = nullptr; 1284 fInfo.fColors = nullptr;
1285 fInfo.fColorOffsets = nullptr; 1285 fInfo.fColorOffsets = nullptr;
1286 fShaderTransform = shader->getLocalMatrix(); 1286 fShaderTransform = shader->getLocalMatrix();
1287 fImageTileModes[0] = fImageTileModes[1] = SkShader::kClamp_TileMode; 1287 fImageTileModes[0] = fImageTileModes[1] = SkShader::kClamp_TileMode;
1288 1288
1289 fType = shader->asAGradient(&fInfo); 1289 fType = shader->asAGradient(&fInfo);
1290 1290
1291 if (fType == SkShader::kNone_GradientType) { 1291 if (fType == SkShader::kNone_GradientType) {
1292 SkMatrix matrix; 1292 if (!shader->isABitmap(&fImage, nullptr, fImageTileModes)) {
1293 if (shader->isABitmap(&fImage, &matrix, fImageTileModes)) {
1294 SkASSERT(matrix.isIdentity());
1295 } else {
1296 // Generic fallback for unsupported shaders: 1293 // Generic fallback for unsupported shaders:
1297 // * allocate a bbox-sized bitmap 1294 // * allocate a bbox-sized bitmap
1298 // * shade the whole area 1295 // * shade the whole area
1299 // * use the result as a bitmap shader 1296 // * use the result as a bitmap shader
1300 1297
1301 // bbox is in device space. While that's exactly what we want for si zing our bitmap, 1298 // bbox is in device space. While that's exactly what we want for si zing our bitmap,
1302 // we need to map it into shader space for adjustments (to match 1299 // we need to map it into shader space for adjustments (to match
1303 // SkPDFImageShader::Create's behavior). 1300 // SkPDFImageShader::Create's behavior).
1304 SkRect shaderRect = SkRect::Make(bbox); 1301 SkRect shaderRect = SkRect::Make(bbox);
1305 if (!inverse_transform_bbox(canvasTransform, &shaderRect)) { 1302 if (!inverse_transform_bbox(canvasTransform, &shaderRect)) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 return false; 1408 return false;
1412 } 1409 }
1413 1410
1414 void SkPDFShader::State::AllocateGradientInfoStorage() { 1411 void SkPDFShader::State::AllocateGradientInfoStorage() {
1415 fColorData.set(sk_malloc_throw( 1412 fColorData.set(sk_malloc_throw(
1416 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1413 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1417 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1414 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1418 fInfo.fColorOffsets = 1415 fInfo.fColorOffsets =
1419 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1416 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1420 } 1417 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | tests/ShaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698