| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
| 9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
| 10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 case kIndex_8_SkColorType: | 24 case kIndex_8_SkColorType: |
| 25 case kN32_SkColorType: | 25 case kN32_SkColorType: |
| 26 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) | 26 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) |
| 27 return true; | 27 return true; |
| 28 default: | 28 default: |
| 29 break; | 29 break; |
| 30 } | 30 } |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 | 33 |
| 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, | 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo
de tmy, |
| 35 TileMode tmx, TileMode tmy) { | 35 const SkMatrix* localMatrix) |
| 36 : INHERITED(localMatrix) { |
| 36 fRawBitmap = src; | 37 fRawBitmap = src; |
| 37 fTileModeX = (uint8_t)tmx; | 38 fTileModeX = (uint8_t)tmx; |
| 38 fTileModeY = (uint8_t)tmy; | 39 fTileModeY = (uint8_t)tmy; |
| 39 } | 40 } |
| 40 | 41 |
| 41 SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) | 42 SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) |
| 42 : INHERITED(buffer) { | 43 : INHERITED(buffer) { |
| 43 buffer.readBitmap(&fRawBitmap); | 44 buffer.readBitmap(&fRawBitmap); |
| 44 fRawBitmap.setImmutable(); | 45 fRawBitmap.setImmutable(); |
| 45 fTileModeX = buffer.readUInt(); | 46 fTileModeX = buffer.readUInt(); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it | 341 // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it |
| 341 // communicates between its matrix-proc and its sampler-proc. Until we can | 342 // communicates between its matrix-proc and its sampler-proc. Until we can |
| 342 // widen that, we have to reject bitmaps that are larger. | 343 // widen that, we have to reject bitmaps that are larger. |
| 343 // | 344 // |
| 344 const int maxSize = 65535; | 345 const int maxSize = 65535; |
| 345 | 346 |
| 346 return bm.width() > maxSize || bm.height() > maxSize; | 347 return bm.width() > maxSize || bm.height() > maxSize; |
| 347 } | 348 } |
| 348 | 349 |
| 349 SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx, | 350 SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx, |
| 350 SkShader::TileMode tmy, SkTBlitterAllocator* allocator) { | 351 SkShader::TileMode tmy, const SkMatrix* localMatrix, SkTBlitterAllocator
* allocator) { |
| 351 SkShader* shader; | 352 SkShader* shader; |
| 352 SkColor color; | 353 SkColor color; |
| 353 if (src.isNull() || bitmapIsTooBig(src)) { | 354 if (src.isNull() || bitmapIsTooBig(src)) { |
| 354 if (NULL == allocator) { | 355 if (NULL == allocator) { |
| 355 shader = SkNEW(SkEmptyShader); | 356 shader = SkNEW(SkEmptyShader); |
| 356 } else { | 357 } else { |
| 357 shader = allocator->createT<SkEmptyShader>(); | 358 shader = allocator->createT<SkEmptyShader>(); |
| 358 } | 359 } |
| 359 } | 360 } |
| 360 else if (canUseColorShader(src, &color)) { | 361 else if (canUseColorShader(src, &color)) { |
| 361 if (NULL == allocator) { | 362 if (NULL == allocator) { |
| 362 shader = SkNEW_ARGS(SkColorShader, (color)); | 363 shader = SkNEW_ARGS(SkColorShader, (color)); |
| 363 } else { | 364 } else { |
| 364 shader = allocator->createT<SkColorShader>(color); | 365 shader = allocator->createT<SkColorShader>(color); |
| 365 } | 366 } |
| 366 } else { | 367 } else { |
| 367 if (NULL == allocator) { | 368 if (NULL == allocator) { |
| 368 shader = SkNEW_ARGS(SkBitmapProcShader, (src, tmx, tmy)); | 369 shader = SkNEW_ARGS(SkBitmapProcShader, (src, tmx, tmy, localMatrix)
); |
| 369 } else { | 370 } else { |
| 370 shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy); | 371 shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy, local
Matrix); |
| 371 } | 372 } |
| 372 } | 373 } |
| 373 return shader; | 374 return shader; |
| 374 } | 375 } |
| 375 | 376 |
| 376 /////////////////////////////////////////////////////////////////////////////// | 377 /////////////////////////////////////////////////////////////////////////////// |
| 377 | 378 |
| 378 #ifndef SK_IGNORE_TO_STRING | 379 #ifndef SK_IGNORE_TO_STRING |
| 379 void SkBitmapProcShader::toString(SkString* str) const { | 380 void SkBitmapProcShader::toString(SkString* str) const { |
| 380 static const char* gTileModeName[SkShader::kTileModeCount] = { | 381 static const char* gTileModeName[SkShader::kTileModeCount] = { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 GrEffectRef* effect = NULL; | 487 GrEffectRef* effect = NULL; |
| 487 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { | 488 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { |
| 488 effect = GrBicubicEffect::Create(texture, matrix, tm); | 489 effect = GrBicubicEffect::Create(texture, matrix, tm); |
| 489 } else { | 490 } else { |
| 490 effect = GrSimpleTextureEffect::Create(texture, matrix, params); | 491 effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
| 491 } | 492 } |
| 492 GrUnlockAndUnrefCachedBitmapTexture(texture); | 493 GrUnlockAndUnrefCachedBitmapTexture(texture); |
| 493 return effect; | 494 return effect; |
| 494 } | 495 } |
| 495 #endif | 496 #endif |
| OLD | NEW |