- Timestamp:
- 04/23/07 07:16:40 (21 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r21022 r21035 66 66 67 67 cairo_t* context; 68 cairo_user_data_key_t opacityKey; 68 69 }; 69 70 … … 469 470 void GraphicsContext::translate(float x, float y) 470 471 { 472 if (paintingDisabled()) 473 return; 471 474 cairo_t* context = m_data->context; 472 475 cairo_translate(context, x, y); … … 495 498 void GraphicsContext::setPlatformStrokeThickness(float strokeThickness) 496 499 { 500 if (paintingDisabled()) 501 return; 497 502 cairo_set_line_width(m_data->context, strokeThickness); 498 503 } … … 565 570 } 566 571 567 void GraphicsContext::beginTransparencyLayer(float) 568 { 569 notImplemented(); 572 void GraphicsContext::beginTransparencyLayer(float opacity) 573 { 574 if (paintingDisabled()) 575 return; 576 577 ASSERT(opacity >= 0 && opacity <= 1); 578 579 cairo_t* context = m_data->context; 580 cairo_push_group(context); 581 // We insert the opacity into a Cairo surface data slot. 582 // Rather than passing a pointer, we store the opacity value directly. 583 void* odata = reinterpret_cast<void*>(static_cast<unsigned int>(opacity * UINT_MAX)); 584 cairo_surface_set_user_data(cairo_get_target(context), &m_data->opacityKey, odata, NULL); 570 585 } 571 586 572 587 void GraphicsContext::endTransparencyLayer() 573 588 { 574 notImplemented(); 589 if (paintingDisabled()) 590 return; 591 592 cairo_t* context = m_data->context; 593 void* odata = cairo_surface_get_user_data(cairo_get_target(context), &m_data->opacityKey); 594 float opacity = static_cast<float>(reinterpret_cast<unsigned int>(odata)) / UINT_MAX; 595 596 ASSERT(opacity >= 0 && opacity <= 1); 597 598 cairo_pop_group_to_source(context); 599 cairo_paint_with_alpha(context, opacity); 575 600 } 576 601 … … 675 700 void GraphicsContext::setCompositeOperation(CompositeOperator op) 676 701 { 702 if (paintingDisabled()) 703 return; 677 704 cairo_set_operator(m_data->context, toCairoOperator(op)); 678 705 } … … 683 710 } 684 711 685 void GraphicsContext::rotate(float) 686 { 687 notImplemented(); 688 } 689 690 void GraphicsContext::scale(const FloatSize&) 691 { 692 notImplemented(); 712 void GraphicsContext::rotate(float angle) 713 { 714 if (paintingDisabled()) 715 return; 716 cairo_rotate(m_data->context, angle); 717 } 718 719 void GraphicsContext::scale(const FloatSize& size) 720 { 721 if (paintingDisabled()) 722 return; 723 cairo_scale(m_data->context, size.width(), size.height()); 693 724 } 694 725