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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 if (rec->fInfo.fPostTranslate) { | 347 if (rec->fInfo.fPostTranslate) { |
348 str->append("true "); | 348 str->append("true "); |
349 } else { | 349 } else { |
350 str->append("false "); | 350 str->append("false "); |
351 } | 351 } |
352 | 352 |
353 rec->fPaint.toString(str); | 353 rec->fPaint.toString(str); |
354 rec = rec->fNext; | 354 rec = rec->fNext; |
355 } | 355 } |
356 } | 356 } |
| 357 |
| 358 SkLayerDrawLooperBuilder::SkLayerDrawLooperBuilder() |
| 359 : fRecs(NULL), |
| 360 fTopRec(NULL), |
| 361 fCount(0) { |
| 362 } |
| 363 |
| 364 SkLayerDrawLooperBuilder::~SkLayerDrawLooperBuilder() { |
| 365 SkLayerDrawLooper::Rec* rec = fRecs; |
| 366 while (rec) { |
| 367 SkLayerDrawLooper::Rec* next = rec->fNext; |
| 368 SkDELETE(rec); |
| 369 rec = next; |
| 370 } |
| 371 } |
| 372 |
| 373 SkPaint* SkLayerDrawLooperBuilder::addLayer( |
| 374 const SkLayerDrawLooper::LayerInfo& info) { |
| 375 fCount += 1; |
| 376 |
| 377 SkLayerDrawLooper::Rec* rec = SkNEW(SkLayerDrawLooper::Rec); |
| 378 rec->fNext = fRecs; |
| 379 rec->fInfo = info; |
| 380 fRecs = rec; |
| 381 if (NULL == fTopRec) { |
| 382 fTopRec = rec; |
| 383 } |
| 384 |
| 385 return &rec->fPaint; |
| 386 } |
| 387 |
| 388 void SkLayerDrawLooperBuilder::addLayer(SkScalar dx, SkScalar dy) { |
| 389 SkLayerDrawLooper::LayerInfo info; |
| 390 |
| 391 info.fOffset.set(dx, dy); |
| 392 (void)this->addLayer(info); |
| 393 } |
| 394 |
| 395 SkPaint* SkLayerDrawLooperBuilder::addLayerOnTop( |
| 396 const SkLayerDrawLooper::LayerInfo& info) { |
| 397 fCount += 1; |
| 398 |
| 399 SkLayerDrawLooper::Rec* rec = SkNEW(SkLayerDrawLooper::Rec); |
| 400 rec->fNext = NULL; |
| 401 rec->fInfo = info; |
| 402 if (NULL == fRecs) { |
| 403 fRecs = rec; |
| 404 } else { |
| 405 SkASSERT(NULL != fTopRec); |
| 406 fTopRec->fNext = rec; |
| 407 } |
| 408 fTopRec = rec; |
| 409 |
| 410 return &rec->fPaint; |
| 411 } |
| 412 |
| 413 SkDrawLooper* SkLayerDrawLooperBuilder::createLooper() { |
| 414 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper); |
| 415 looper->fCount = fCount; |
| 416 looper->fRecs = fRecs; |
| 417 |
| 418 fCount = 0; |
| 419 fRecs = NULL; |
| 420 fTopRec = NULL; |
| 421 |
| 422 return looper; |
| 423 } |
357 #endif | 424 #endif |
OLD | NEW |