OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_PAINT_PAINT_OP_BUFFER_H_ | 5 #ifndef CC_PAINT_PAINT_OP_BUFFER_H_ |
6 #define CC_PAINT_PAINT_OP_BUFFER_H_ | 6 #define CC_PAINT_PAINT_OP_BUFFER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Translate, | 72 Translate, |
73 LastPaintOpType = Translate, | 73 LastPaintOpType = Translate, |
74 }; | 74 }; |
75 | 75 |
76 struct CC_PAINT_EXPORT PaintOp { | 76 struct CC_PAINT_EXPORT PaintOp { |
77 uint32_t type : 8; | 77 uint32_t type : 8; |
78 uint32_t skip : 24; | 78 uint32_t skip : 24; |
79 | 79 |
80 PaintOpType GetType() const { return static_cast<PaintOpType>(type); } | 80 PaintOpType GetType() const { return static_cast<PaintOpType>(type); } |
81 | 81 |
| 82 // Subclasses should provide a static Raster() method which is called from |
| 83 // here. The Raster method should take a const PaintOp* parameter. It is |
| 84 // static with a pointer to the base type so that we can use it as a function |
| 85 // pointer. |
82 void Raster(SkCanvas* canvas, const SkMatrix& original_ctm) const; | 86 void Raster(SkCanvas* canvas, const SkMatrix& original_ctm) const; |
83 bool IsDrawOp() const; | 87 bool IsDrawOp() const; |
84 | 88 |
85 // Only valid for draw ops. | 89 // Only valid for draw ops. |
86 void RasterWithAlpha(SkCanvas* canvas, uint8_t alpha) const; | 90 void RasterWithAlpha(SkCanvas* canvas, uint8_t alpha) const; |
87 | 91 |
88 int CountSlowPaths() const { return 0; } | 92 int CountSlowPaths() const { return 0; } |
89 int CountSlowPathsFromFlags() const { return 0; } | 93 int CountSlowPathsFromFlags() const { return 0; } |
90 | 94 |
91 // Returns the number of bytes used by this op in referenced sub records | 95 // Returns the number of bytes used by this op in referenced sub records |
92 // and display lists. This doesn't count other objects like paths or blobs. | 96 // and display lists. This doesn't count other objects like paths or blobs. |
93 size_t AdditionalBytesUsed() const { return 0; } | 97 size_t AdditionalBytesUsed() const { return 0; } |
94 | 98 |
95 static constexpr bool kIsDrawOp = false; | 99 static constexpr bool kIsDrawOp = false; |
96 static constexpr bool kHasPaintFlags = false; | 100 static constexpr bool kHasPaintFlags = false; |
97 static SkRect kUnsetRect; | 101 static SkRect kUnsetRect; |
98 }; | 102 }; |
99 | 103 |
100 struct CC_PAINT_EXPORT PaintOpWithFlags : PaintOp { | 104 struct CC_PAINT_EXPORT PaintOpWithFlags : PaintOp { |
101 static constexpr bool kHasPaintFlags = true; | 105 static constexpr bool kHasPaintFlags = true; |
102 | 106 |
103 explicit PaintOpWithFlags(const PaintFlags& flags) : flags(flags) {} | 107 explicit PaintOpWithFlags(const PaintFlags& flags) : flags(flags) {} |
104 | 108 |
105 int CountSlowPathsFromFlags() const { return flags.getPathEffect() ? 1 : 0; } | 109 int CountSlowPathsFromFlags() const { return flags.getPathEffect() ? 1 : 0; } |
106 | 110 |
| 111 // Subclasses should provide a static RasterWithFlags() method which is called |
| 112 // from the Raster() method. The RasterWithFlags() should use the PaintFlags |
| 113 // passed to it, instead of the |flags| member directly, as some callers may |
| 114 // provide a modified PaintFlags. The RasterWithFlags() method is static with |
| 115 // a const PaintOpWithFlags* parameter so that it can be used as a function |
| 116 // pointer. |
107 PaintFlags flags; | 117 PaintFlags flags; |
108 }; | 118 }; |
109 | 119 |
110 struct CC_PAINT_EXPORT PaintOpWithData : PaintOpWithFlags { | 120 struct CC_PAINT_EXPORT PaintOpWithData : PaintOpWithFlags { |
111 // Having data is just a helper for ops that have a varying amount of data and | 121 // Having data is just a helper for ops that have a varying amount of data and |
112 // want a way to store that inline. This is for ops that pass in a | 122 // want a way to store that inline. This is for ops that pass in a |
113 // void* and a length. The void* data is assumed to not have any alignment | 123 // void* and a length. The void* data is assumed to not have any alignment |
114 // requirements. | 124 // requirements. |
115 PaintOpWithData(const PaintFlags& flags, size_t bytes) | 125 PaintOpWithData(const PaintFlags& flags, size_t bytes) |
116 : PaintOpWithFlags(flags), bytes(bytes) {} | 126 : PaintOpWithFlags(flags), bytes(bytes) {} |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 SkScalar sweep_angle, | 292 SkScalar sweep_angle, |
283 bool use_center, | 293 bool use_center, |
284 const PaintFlags& flags) | 294 const PaintFlags& flags) |
285 : PaintOpWithFlags(flags), | 295 : PaintOpWithFlags(flags), |
286 oval(oval), | 296 oval(oval), |
287 start_angle(start_angle), | 297 start_angle(start_angle), |
288 sweep_angle(sweep_angle), | 298 sweep_angle(sweep_angle), |
289 use_center(use_center) {} | 299 use_center(use_center) {} |
290 static void Raster(const PaintOp* op, | 300 static void Raster(const PaintOp* op, |
291 SkCanvas* canvas, | 301 SkCanvas* canvas, |
292 const SkMatrix& original_ctm); | 302 const SkMatrix& original_ctm) { |
| 303 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 304 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 305 } |
| 306 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 307 const PaintFlags* flags, |
| 308 SkCanvas* canvas, |
| 309 const SkMatrix& original_ctm); |
293 | 310 |
294 SkRect oval; | 311 SkRect oval; |
295 SkScalar start_angle; | 312 SkScalar start_angle; |
296 SkScalar sweep_angle; | 313 SkScalar sweep_angle; |
297 bool use_center; | 314 bool use_center; |
298 }; | 315 }; |
299 | 316 |
300 struct CC_PAINT_EXPORT DrawCircleOp final : PaintOpWithFlags { | 317 struct CC_PAINT_EXPORT DrawCircleOp final : PaintOpWithFlags { |
301 static constexpr PaintOpType kType = PaintOpType::DrawCircle; | 318 static constexpr PaintOpType kType = PaintOpType::DrawCircle; |
302 static constexpr bool kIsDrawOp = true; | 319 static constexpr bool kIsDrawOp = true; |
303 DrawCircleOp(SkScalar cx, | 320 DrawCircleOp(SkScalar cx, |
304 SkScalar cy, | 321 SkScalar cy, |
305 SkScalar radius, | 322 SkScalar radius, |
306 const PaintFlags& flags) | 323 const PaintFlags& flags) |
307 : PaintOpWithFlags(flags), cx(cx), cy(cy), radius(radius) {} | 324 : PaintOpWithFlags(flags), cx(cx), cy(cy), radius(radius) {} |
308 static void Raster(const PaintOp* op, | 325 static void Raster(const PaintOp* op, |
309 SkCanvas* canvas, | 326 SkCanvas* canvas, |
310 const SkMatrix& original_ctm); | 327 const SkMatrix& original_ctm) { |
| 328 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 329 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 330 } |
| 331 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 332 const PaintFlags* flags, |
| 333 SkCanvas* canvas, |
| 334 const SkMatrix& original_ctm); |
311 | 335 |
312 SkScalar cx; | 336 SkScalar cx; |
313 SkScalar cy; | 337 SkScalar cy; |
314 SkScalar radius; | 338 SkScalar radius; |
315 }; | 339 }; |
316 | 340 |
317 struct CC_PAINT_EXPORT DrawColorOp final : PaintOp { | 341 struct CC_PAINT_EXPORT DrawColorOp final : PaintOp { |
318 static constexpr PaintOpType kType = PaintOpType::DrawColor; | 342 static constexpr PaintOpType kType = PaintOpType::DrawColor; |
319 static constexpr bool kIsDrawOp = true; | 343 static constexpr bool kIsDrawOp = true; |
320 DrawColorOp(SkColor color, SkBlendMode mode) : color(color), mode(mode) {} | 344 DrawColorOp(SkColor color, SkBlendMode mode) : color(color), mode(mode) {} |
(...skipping 26 matching lines...) Expand all Loading... |
347 | 371 |
348 struct CC_PAINT_EXPORT DrawDRRectOp final : PaintOpWithFlags { | 372 struct CC_PAINT_EXPORT DrawDRRectOp final : PaintOpWithFlags { |
349 static constexpr PaintOpType kType = PaintOpType::DrawDRRect; | 373 static constexpr PaintOpType kType = PaintOpType::DrawDRRect; |
350 static constexpr bool kIsDrawOp = true; | 374 static constexpr bool kIsDrawOp = true; |
351 DrawDRRectOp(const SkRRect& outer, | 375 DrawDRRectOp(const SkRRect& outer, |
352 const SkRRect& inner, | 376 const SkRRect& inner, |
353 const PaintFlags& flags) | 377 const PaintFlags& flags) |
354 : PaintOpWithFlags(flags), outer(outer), inner(inner) {} | 378 : PaintOpWithFlags(flags), outer(outer), inner(inner) {} |
355 static void Raster(const PaintOp* op, | 379 static void Raster(const PaintOp* op, |
356 SkCanvas* canvas, | 380 SkCanvas* canvas, |
357 const SkMatrix& original_ctm); | 381 const SkMatrix& original_ctm) { |
| 382 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 383 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 384 } |
| 385 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 386 const PaintFlags* flags, |
| 387 SkCanvas* canvas, |
| 388 const SkMatrix& original_ctm); |
358 | 389 |
359 SkRRect outer; | 390 SkRRect outer; |
360 SkRRect inner; | 391 SkRRect inner; |
361 }; | 392 }; |
362 | 393 |
363 struct CC_PAINT_EXPORT DrawImageOp final : PaintOpWithFlags { | 394 struct CC_PAINT_EXPORT DrawImageOp final : PaintOpWithFlags { |
364 static constexpr PaintOpType kType = PaintOpType::DrawImage; | 395 static constexpr PaintOpType kType = PaintOpType::DrawImage; |
365 static constexpr bool kIsDrawOp = true; | 396 static constexpr bool kIsDrawOp = true; |
366 DrawImageOp(const PaintImage& image, | 397 DrawImageOp(const PaintImage& image, |
367 SkScalar left, | 398 SkScalar left, |
368 SkScalar top, | 399 SkScalar top, |
369 const PaintFlags* flags); | 400 const PaintFlags* flags); |
370 ~DrawImageOp(); | 401 ~DrawImageOp(); |
371 static void Raster(const PaintOp* op, | 402 static void Raster(const PaintOp* op, |
372 SkCanvas* canvas, | 403 SkCanvas* canvas, |
373 const SkMatrix& original_ctm); | 404 const SkMatrix& original_ctm) { |
| 405 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 406 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 407 } |
| 408 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 409 const PaintFlags* flags, |
| 410 SkCanvas* canvas, |
| 411 const SkMatrix& original_ctm); |
374 | 412 |
375 PaintImage image; | 413 PaintImage image; |
376 SkScalar left; | 414 SkScalar left; |
377 SkScalar top; | 415 SkScalar top; |
378 }; | 416 }; |
379 | 417 |
380 struct CC_PAINT_EXPORT DrawImageRectOp final : PaintOpWithFlags { | 418 struct CC_PAINT_EXPORT DrawImageRectOp final : PaintOpWithFlags { |
381 static constexpr PaintOpType kType = PaintOpType::DrawImageRect; | 419 static constexpr PaintOpType kType = PaintOpType::DrawImageRect; |
382 static constexpr bool kIsDrawOp = true; | 420 static constexpr bool kIsDrawOp = true; |
383 DrawImageRectOp(const PaintImage& image, | 421 DrawImageRectOp(const PaintImage& image, |
384 const SkRect& src, | 422 const SkRect& src, |
385 const SkRect& dst, | 423 const SkRect& dst, |
386 const PaintFlags* flags, | 424 const PaintFlags* flags, |
387 PaintCanvas::SrcRectConstraint constraint); | 425 PaintCanvas::SrcRectConstraint constraint); |
388 ~DrawImageRectOp(); | 426 ~DrawImageRectOp(); |
389 static void Raster(const PaintOp* op, | 427 static void Raster(const PaintOp* op, |
390 SkCanvas* canvas, | 428 SkCanvas* canvas, |
391 const SkMatrix& original_ctm); | 429 const SkMatrix& original_ctm) { |
| 430 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 431 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 432 } |
| 433 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 434 const PaintFlags* flags, |
| 435 SkCanvas* canvas, |
| 436 const SkMatrix& original_ctm); |
392 | 437 |
393 PaintImage image; | 438 PaintImage image; |
394 SkRect src; | 439 SkRect src; |
395 SkRect dst; | 440 SkRect dst; |
396 PaintCanvas::SrcRectConstraint constraint; | 441 PaintCanvas::SrcRectConstraint constraint; |
397 }; | 442 }; |
398 | 443 |
399 struct CC_PAINT_EXPORT DrawIRectOp final : PaintOpWithFlags { | 444 struct CC_PAINT_EXPORT DrawIRectOp final : PaintOpWithFlags { |
400 static constexpr PaintOpType kType = PaintOpType::DrawIRect; | 445 static constexpr PaintOpType kType = PaintOpType::DrawIRect; |
401 static constexpr bool kIsDrawOp = true; | 446 static constexpr bool kIsDrawOp = true; |
402 DrawIRectOp(const SkIRect& rect, const PaintFlags& flags) | 447 DrawIRectOp(const SkIRect& rect, const PaintFlags& flags) |
403 : PaintOpWithFlags(flags), rect(rect) {} | 448 : PaintOpWithFlags(flags), rect(rect) {} |
404 static void Raster(const PaintOp* op, | 449 static void Raster(const PaintOp* op, |
405 SkCanvas* canvas, | 450 SkCanvas* canvas, |
406 const SkMatrix& original_ctm); | 451 const SkMatrix& original_ctm) { |
| 452 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 453 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 454 } |
| 455 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 456 const PaintFlags* flags, |
| 457 SkCanvas* canvas, |
| 458 const SkMatrix& original_ctm); |
407 | 459 |
408 SkIRect rect; | 460 SkIRect rect; |
409 }; | 461 }; |
410 | 462 |
411 struct CC_PAINT_EXPORT DrawLineOp final : PaintOpWithFlags { | 463 struct CC_PAINT_EXPORT DrawLineOp final : PaintOpWithFlags { |
412 static constexpr PaintOpType kType = PaintOpType::DrawLine; | 464 static constexpr PaintOpType kType = PaintOpType::DrawLine; |
413 static constexpr bool kIsDrawOp = true; | 465 static constexpr bool kIsDrawOp = true; |
414 DrawLineOp(SkScalar x0, | 466 DrawLineOp(SkScalar x0, |
415 SkScalar y0, | 467 SkScalar y0, |
416 SkScalar x1, | 468 SkScalar x1, |
417 SkScalar y1, | 469 SkScalar y1, |
418 const PaintFlags& flags) | 470 const PaintFlags& flags) |
419 : PaintOpWithFlags(flags), x0(x0), y0(y0), x1(x1), y1(y1) {} | 471 : PaintOpWithFlags(flags), x0(x0), y0(y0), x1(x1), y1(y1) {} |
420 static void Raster(const PaintOp* op, | 472 static void Raster(const PaintOp* op, |
421 SkCanvas* canvas, | 473 SkCanvas* canvas, |
422 const SkMatrix& original_ctm); | 474 const SkMatrix& original_ctm) { |
| 475 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 476 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 477 } |
| 478 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 479 const PaintFlags* flags, |
| 480 SkCanvas* canvas, |
| 481 const SkMatrix& original_ctm); |
| 482 |
423 int CountSlowPaths() const; | 483 int CountSlowPaths() const; |
424 | 484 |
425 SkScalar x0; | 485 SkScalar x0; |
426 SkScalar y0; | 486 SkScalar y0; |
427 SkScalar x1; | 487 SkScalar x1; |
428 SkScalar y1; | 488 SkScalar y1; |
429 }; | 489 }; |
430 | 490 |
431 struct CC_PAINT_EXPORT DrawOvalOp final : PaintOpWithFlags { | 491 struct CC_PAINT_EXPORT DrawOvalOp final : PaintOpWithFlags { |
432 static constexpr PaintOpType kType = PaintOpType::DrawOval; | 492 static constexpr PaintOpType kType = PaintOpType::DrawOval; |
433 static constexpr bool kIsDrawOp = true; | 493 static constexpr bool kIsDrawOp = true; |
434 DrawOvalOp(const SkRect& oval, const PaintFlags& flags) | 494 DrawOvalOp(const SkRect& oval, const PaintFlags& flags) |
435 : PaintOpWithFlags(flags), oval(oval) {} | 495 : PaintOpWithFlags(flags), oval(oval) {} |
436 static void Raster(const PaintOp* op, | 496 static void Raster(const PaintOp* op, |
437 SkCanvas* canvas, | 497 SkCanvas* canvas, |
438 const SkMatrix& original_ctm); | 498 const SkMatrix& original_ctm) { |
| 499 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 500 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 501 } |
| 502 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 503 const PaintFlags* flags, |
| 504 SkCanvas* canvas, |
| 505 const SkMatrix& original_ctm); |
439 | 506 |
440 SkRect oval; | 507 SkRect oval; |
441 }; | 508 }; |
442 | 509 |
443 struct CC_PAINT_EXPORT DrawPathOp final : PaintOpWithFlags { | 510 struct CC_PAINT_EXPORT DrawPathOp final : PaintOpWithFlags { |
444 static constexpr PaintOpType kType = PaintOpType::DrawPath; | 511 static constexpr PaintOpType kType = PaintOpType::DrawPath; |
445 static constexpr bool kIsDrawOp = true; | 512 static constexpr bool kIsDrawOp = true; |
446 DrawPathOp(const SkPath& path, const PaintFlags& flags) | 513 DrawPathOp(const SkPath& path, const PaintFlags& flags) |
447 : PaintOpWithFlags(flags), path(path) {} | 514 : PaintOpWithFlags(flags), path(path) {} |
448 static void Raster(const PaintOp* op, | 515 static void Raster(const PaintOp* op, |
449 SkCanvas* canvas, | 516 SkCanvas* canvas, |
450 const SkMatrix& original_ctm); | 517 const SkMatrix& original_ctm) { |
| 518 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 519 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 520 } |
| 521 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 522 const PaintFlags* flags, |
| 523 SkCanvas* canvas, |
| 524 const SkMatrix& original_ctm); |
451 int CountSlowPaths() const; | 525 int CountSlowPaths() const; |
452 | 526 |
453 ThreadsafePath path; | 527 ThreadsafePath path; |
454 }; | 528 }; |
455 | 529 |
456 struct CC_PAINT_EXPORT DrawPosTextOp final : PaintOpWithArray<SkPoint> { | 530 struct CC_PAINT_EXPORT DrawPosTextOp final : PaintOpWithArray<SkPoint> { |
457 static constexpr PaintOpType kType = PaintOpType::DrawPosText; | 531 static constexpr PaintOpType kType = PaintOpType::DrawPosText; |
458 static constexpr bool kIsDrawOp = true; | 532 static constexpr bool kIsDrawOp = true; |
459 DrawPosTextOp(size_t bytes, size_t count, const PaintFlags& flags); | 533 DrawPosTextOp(size_t bytes, size_t count, const PaintFlags& flags); |
460 ~DrawPosTextOp(); | 534 ~DrawPosTextOp(); |
461 static void Raster(const PaintOp* op, | 535 static void Raster(const PaintOp* op, |
462 SkCanvas* canvas, | 536 SkCanvas* canvas, |
463 const SkMatrix& original_ctm); | 537 const SkMatrix& original_ctm) { |
| 538 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 539 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 540 } |
| 541 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 542 const PaintFlags* flags, |
| 543 SkCanvas* canvas, |
| 544 const SkMatrix& original_ctm); |
| 545 |
464 const void* GetData() const { return GetDataForThis(this); } | 546 const void* GetData() const { return GetDataForThis(this); } |
465 void* GetData() { return GetDataForThis(this); } | 547 void* GetData() { return GetDataForThis(this); } |
466 const SkPoint* GetArray() const { return GetArrayForThis(this); } | 548 const SkPoint* GetArray() const { return GetArrayForThis(this); } |
467 SkPoint* GetArray() { return GetArrayForThis(this); } | 549 SkPoint* GetArray() { return GetArrayForThis(this); } |
468 }; | 550 }; |
469 | 551 |
470 struct CC_PAINT_EXPORT DrawRecordOp final : PaintOp { | 552 struct CC_PAINT_EXPORT DrawRecordOp final : PaintOp { |
471 static constexpr PaintOpType kType = PaintOpType::DrawRecord; | 553 static constexpr PaintOpType kType = PaintOpType::DrawRecord; |
472 static constexpr bool kIsDrawOp = true; | 554 static constexpr bool kIsDrawOp = true; |
473 explicit DrawRecordOp(sk_sp<const PaintRecord> record); | 555 explicit DrawRecordOp(sk_sp<const PaintRecord> record); |
474 ~DrawRecordOp(); | 556 ~DrawRecordOp(); |
475 static void Raster(const PaintOp* op, | 557 static void Raster(const PaintOp* op, |
476 SkCanvas* canvas, | 558 SkCanvas* canvas, |
477 const SkMatrix& original_ctm); | 559 const SkMatrix& original_ctm); |
478 size_t AdditionalBytesUsed() const; | 560 size_t AdditionalBytesUsed() const; |
479 | 561 |
480 sk_sp<const PaintRecord> record; | 562 sk_sp<const PaintRecord> record; |
481 }; | 563 }; |
482 | 564 |
483 struct CC_PAINT_EXPORT DrawRectOp final : PaintOpWithFlags { | 565 struct CC_PAINT_EXPORT DrawRectOp final : PaintOpWithFlags { |
484 static constexpr PaintOpType kType = PaintOpType::DrawRect; | 566 static constexpr PaintOpType kType = PaintOpType::DrawRect; |
485 static constexpr bool kIsDrawOp = true; | 567 static constexpr bool kIsDrawOp = true; |
486 DrawRectOp(const SkRect& rect, const PaintFlags& flags) | 568 DrawRectOp(const SkRect& rect, const PaintFlags& flags) |
487 : PaintOpWithFlags(flags), rect(rect) {} | 569 : PaintOpWithFlags(flags), rect(rect) {} |
488 static void Raster(const PaintOp* op, | 570 static void Raster(const PaintOp* op, |
489 SkCanvas* canvas, | 571 SkCanvas* canvas, |
490 const SkMatrix& original_ctm); | 572 const SkMatrix& original_ctm) { |
| 573 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 574 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 575 } |
| 576 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 577 const PaintFlags* flags, |
| 578 SkCanvas* canvas, |
| 579 const SkMatrix& original_ctm); |
491 | 580 |
492 SkRect rect; | 581 SkRect rect; |
493 }; | 582 }; |
494 | 583 |
495 struct CC_PAINT_EXPORT DrawRRectOp final : PaintOpWithFlags { | 584 struct CC_PAINT_EXPORT DrawRRectOp final : PaintOpWithFlags { |
496 static constexpr PaintOpType kType = PaintOpType::DrawRRect; | 585 static constexpr PaintOpType kType = PaintOpType::DrawRRect; |
497 static constexpr bool kIsDrawOp = true; | 586 static constexpr bool kIsDrawOp = true; |
498 DrawRRectOp(const SkRRect& rrect, const PaintFlags& flags) | 587 DrawRRectOp(const SkRRect& rrect, const PaintFlags& flags) |
499 : PaintOpWithFlags(flags), rrect(rrect) {} | 588 : PaintOpWithFlags(flags), rrect(rrect) {} |
500 static void Raster(const PaintOp* op, | 589 static void Raster(const PaintOp* op, |
501 SkCanvas* canvas, | 590 SkCanvas* canvas, |
502 const SkMatrix& original_ctm); | 591 const SkMatrix& original_ctm) { |
| 592 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 593 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 594 } |
| 595 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 596 const PaintFlags* flags, |
| 597 SkCanvas* canvas, |
| 598 const SkMatrix& original_ctm); |
503 | 599 |
504 SkRRect rrect; | 600 SkRRect rrect; |
505 }; | 601 }; |
506 | 602 |
507 struct CC_PAINT_EXPORT DrawTextOp final : PaintOpWithData { | 603 struct CC_PAINT_EXPORT DrawTextOp final : PaintOpWithData { |
508 static constexpr PaintOpType kType = PaintOpType::DrawText; | 604 static constexpr PaintOpType kType = PaintOpType::DrawText; |
509 static constexpr bool kIsDrawOp = true; | 605 static constexpr bool kIsDrawOp = true; |
510 DrawTextOp(size_t bytes, SkScalar x, SkScalar y, const PaintFlags& flags) | 606 DrawTextOp(size_t bytes, SkScalar x, SkScalar y, const PaintFlags& flags) |
511 : PaintOpWithData(flags, bytes), x(x), y(y) {} | 607 : PaintOpWithData(flags, bytes), x(x), y(y) {} |
512 static void Raster(const PaintOp* op, | 608 static void Raster(const PaintOp* op, |
513 SkCanvas* canvas, | 609 SkCanvas* canvas, |
514 const SkMatrix& original_ctm); | 610 const SkMatrix& original_ctm) { |
| 611 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 612 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 613 } |
| 614 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 615 const PaintFlags* flags, |
| 616 SkCanvas* canvas, |
| 617 const SkMatrix& original_ctm); |
515 | 618 |
516 void* GetData() { return GetDataForThis(this); } | 619 void* GetData() { return GetDataForThis(this); } |
517 const void* GetData() const { return GetDataForThis(this); } | 620 const void* GetData() const { return GetDataForThis(this); } |
518 | 621 |
519 SkScalar x; | 622 SkScalar x; |
520 SkScalar y; | 623 SkScalar y; |
521 }; | 624 }; |
522 | 625 |
523 struct CC_PAINT_EXPORT DrawTextBlobOp final : PaintOpWithFlags { | 626 struct CC_PAINT_EXPORT DrawTextBlobOp final : PaintOpWithFlags { |
524 static constexpr PaintOpType kType = PaintOpType::DrawTextBlob; | 627 static constexpr PaintOpType kType = PaintOpType::DrawTextBlob; |
525 static constexpr bool kIsDrawOp = true; | 628 static constexpr bool kIsDrawOp = true; |
526 DrawTextBlobOp(sk_sp<SkTextBlob> blob, | 629 DrawTextBlobOp(sk_sp<SkTextBlob> blob, |
527 SkScalar x, | 630 SkScalar x, |
528 SkScalar y, | 631 SkScalar y, |
529 const PaintFlags& flags); | 632 const PaintFlags& flags); |
530 ~DrawTextBlobOp(); | 633 ~DrawTextBlobOp(); |
531 static void Raster(const PaintOp* op, | 634 static void Raster(const PaintOp* op, |
532 SkCanvas* canvas, | 635 SkCanvas* canvas, |
533 const SkMatrix& original_ctm); | 636 const SkMatrix& original_ctm) { |
| 637 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 638 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 639 } |
| 640 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 641 const PaintFlags* flags, |
| 642 SkCanvas* canvas, |
| 643 const SkMatrix& original_ctm); |
534 | 644 |
535 sk_sp<SkTextBlob> blob; | 645 sk_sp<SkTextBlob> blob; |
536 SkScalar x; | 646 SkScalar x; |
537 SkScalar y; | 647 SkScalar y; |
538 }; | 648 }; |
539 | 649 |
540 struct CC_PAINT_EXPORT NoopOp final : PaintOp { | 650 struct CC_PAINT_EXPORT NoopOp final : PaintOp { |
541 static constexpr PaintOpType kType = PaintOpType::Noop; | 651 static constexpr PaintOpType kType = PaintOpType::Noop; |
542 static void Raster(const PaintOp* op, | 652 static void Raster(const PaintOp* op, |
543 SkCanvas* canvas, | 653 SkCanvas* canvas, |
(...skipping 24 matching lines...) Expand all Loading... |
568 const SkMatrix& original_ctm); | 678 const SkMatrix& original_ctm); |
569 }; | 679 }; |
570 | 680 |
571 struct CC_PAINT_EXPORT SaveLayerOp final : PaintOpWithFlags { | 681 struct CC_PAINT_EXPORT SaveLayerOp final : PaintOpWithFlags { |
572 static constexpr PaintOpType kType = PaintOpType::SaveLayer; | 682 static constexpr PaintOpType kType = PaintOpType::SaveLayer; |
573 SaveLayerOp(const SkRect* bounds, const PaintFlags* flags) | 683 SaveLayerOp(const SkRect* bounds, const PaintFlags* flags) |
574 : PaintOpWithFlags(flags ? *flags : PaintFlags()), | 684 : PaintOpWithFlags(flags ? *flags : PaintFlags()), |
575 bounds(bounds ? *bounds : kUnsetRect) {} | 685 bounds(bounds ? *bounds : kUnsetRect) {} |
576 static void Raster(const PaintOp* op, | 686 static void Raster(const PaintOp* op, |
577 SkCanvas* canvas, | 687 SkCanvas* canvas, |
578 const SkMatrix& original_ctm); | 688 const SkMatrix& original_ctm) { |
| 689 auto* flags_op = static_cast<const PaintOpWithFlags*>(op); |
| 690 RasterWithFlags(flags_op, &flags_op->flags, canvas, original_ctm); |
| 691 } |
| 692 static void RasterWithFlags(const PaintOpWithFlags* op, |
| 693 const PaintFlags* flags, |
| 694 SkCanvas* canvas, |
| 695 const SkMatrix& original_ctm); |
579 | 696 |
580 SkRect bounds; | 697 SkRect bounds; |
581 }; | 698 }; |
582 | 699 |
583 struct CC_PAINT_EXPORT SaveLayerAlphaOp final : PaintOp { | 700 struct CC_PAINT_EXPORT SaveLayerAlphaOp final : PaintOp { |
584 static constexpr PaintOpType kType = PaintOpType::SaveLayerAlpha; | 701 static constexpr PaintOpType kType = PaintOpType::SaveLayerAlpha; |
585 SaveLayerAlphaOp(const SkRect* bounds, uint8_t alpha) | 702 SaveLayerAlphaOp(const SkRect* bounds, uint8_t alpha) |
586 : bounds(bounds ? *bounds : kUnsetRect), alpha(alpha) {} | 703 : bounds(bounds ? *bounds : kUnsetRect), alpha(alpha) {} |
587 static void Raster(const PaintOp* op, | 704 static void Raster(const PaintOp* op, |
588 SkCanvas* canvas, | 705 SkCanvas* canvas, |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 // Record additional bytes used by referenced sub-records and display lists. | 949 // Record additional bytes used by referenced sub-records and display lists. |
833 size_t subrecord_bytes_used_ = 0; | 950 size_t subrecord_bytes_used_ = 0; |
834 SkRect cull_rect_; | 951 SkRect cull_rect_; |
835 | 952 |
836 DISALLOW_COPY_AND_ASSIGN(PaintOpBuffer); | 953 DISALLOW_COPY_AND_ASSIGN(PaintOpBuffer); |
837 }; | 954 }; |
838 | 955 |
839 } // namespace cc | 956 } // namespace cc |
840 | 957 |
841 #endif // CC_PAINT_PAINT_OP_BUFFER_H_ | 958 #endif // CC_PAINT_PAINT_OP_BUFFER_H_ |
OLD | NEW |