OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/plugin/webplugin_proxy.h" | 5 #include "chrome/plugin/webplugin_proxy.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
9 #include "app/win_util.h" | 9 #include "app/win_util.h" |
10 #endif | 10 #endif |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 return success; | 365 return success; |
366 } | 366 } |
367 | 367 |
368 void WebPluginProxy::Paint(const gfx::Rect& rect) { | 368 void WebPluginProxy::Paint(const gfx::Rect& rect) { |
369 #if defined(OS_WIN) | 369 #if defined(OS_WIN) |
370 if (!windowless_hdc_) | 370 if (!windowless_hdc_) |
371 return; | 371 return; |
372 #elif defined(OS_MACOSX) | 372 #elif defined(OS_MACOSX) |
373 if (!windowless_context_.get()) | 373 if (!windowless_context_.get()) |
374 return; | 374 return; |
| 375 #elif defined(OS_LINUX) |
| 376 if (!windowless_canvas_.get()) |
| 377 return; |
375 #endif | 378 #endif |
376 | 379 |
377 // Clear the damaged area so that if the plugin doesn't paint there we won't | 380 // Clear the damaged area so that if the plugin doesn't paint there we won't |
378 // end up with the old values. | 381 // end up with the old values. |
379 gfx::Rect offset_rect = rect; | 382 gfx::Rect offset_rect = rect; |
380 offset_rect.Offset(delegate_->GetRect().origin()); | 383 offset_rect.Offset(delegate_->GetRect().origin()); |
381 #if defined(OS_WIN) | 384 #if defined(OS_WIN) |
382 if (!background_hdc_) { | 385 if (!background_hdc_) { |
383 FillRect(windowless_hdc_, &offset_rect.ToRECT(), | 386 FillRect(windowless_hdc_, &offset_rect.ToRECT(), |
384 static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); | 387 static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); |
(...skipping 23 matching lines...) Expand all Loading... |
408 scoped_cftyperef<CGImageRef> image( | 411 scoped_cftyperef<CGImageRef> image( |
409 CGBitmapContextCreateImage(background_context_)); | 412 CGBitmapContextCreateImage(background_context_)); |
410 scoped_cftyperef<CGImageRef> sub_image( | 413 scoped_cftyperef<CGImageRef> sub_image( |
411 CGImageCreateWithImageInRect(image, rect.ToCGRect())); | 414 CGImageCreateWithImageInRect(image, rect.ToCGRect())); |
412 CGContextDrawImage(background_context_, rect.ToCGRect(), sub_image); | 415 CGContextDrawImage(background_context_, rect.ToCGRect(), sub_image); |
413 } | 416 } |
414 CGContextClipToRect(windowless_context_, rect.ToCGRect()); | 417 CGContextClipToRect(windowless_context_, rect.ToCGRect()); |
415 delegate_->Paint(windowless_context_, rect); | 418 delegate_->Paint(windowless_context_, rect); |
416 CGContextRestoreGState(windowless_context_); | 419 CGContextRestoreGState(windowless_context_); |
417 #else | 420 #else |
418 // TODO(port): windowless painting. | 421 cairo_t* cairo = |
419 NOTIMPLEMENTED(); | 422 windowless_canvas_->getTopPlatformDevice().beginPlatformPaint(); |
| 423 cairo_save(cairo); |
| 424 cairo_rectangle(cairo, rect.x(), rect.y(), rect.width(), rect.height()); |
| 425 cairo_clip(cairo); |
| 426 if (background_canvas_.get()) { |
| 427 cairo_t *background = |
| 428 background_canvas_->getTopPlatformDevice().beginPlatformPaint(); |
| 429 cairo_set_source_surface(cairo, cairo_get_target(background), 0, 0); |
| 430 cairo_paint(cairo); |
| 431 } |
| 432 cairo_translate(cairo, -delegate_->GetRect().x(), -delegate_->GetRect().y()); |
| 433 delegate_->Paint(cairo, offset_rect); |
| 434 cairo_restore(cairo); |
420 #endif | 435 #endif |
421 } | 436 } |
422 | 437 |
423 void WebPluginProxy::UpdateGeometry( | 438 void WebPluginProxy::UpdateGeometry( |
424 const gfx::Rect& window_rect, | 439 const gfx::Rect& window_rect, |
425 const gfx::Rect& clip_rect, | 440 const gfx::Rect& clip_rect, |
426 const TransportDIB::Handle& windowless_buffer, | 441 const TransportDIB::Handle& windowless_buffer, |
427 const TransportDIB::Handle& background_buffer) { | 442 const TransportDIB::Handle& background_buffer) { |
428 gfx::Rect old = delegate_->GetRect(); | 443 gfx::Rect old = delegate_->GetRect(); |
429 gfx::Rect old_clip_rect = delegate_->GetClipRect(); | 444 gfx::Rect old_clip_rect = delegate_->GetClipRect(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 rgb_colorspace, | 566 rgb_colorspace, |
552 kCGImageAlphaPremultipliedFirst | | 567 kCGImageAlphaPremultipliedFirst | |
553 kCGBitmapByteOrder32Host)); | 568 kCGBitmapByteOrder32Host)); |
554 CGContextTranslateCTM(background_context_, 0, | 569 CGContextTranslateCTM(background_context_, 0, |
555 delegate_->GetRect().height()); | 570 delegate_->GetRect().height()); |
556 CGContextScaleCTM(background_context_, 1, -1); | 571 CGContextScaleCTM(background_context_, 1, -1); |
557 } | 572 } |
558 } | 573 } |
559 #elif defined (OS_LINUX) | 574 #elif defined (OS_LINUX) |
560 void WebPluginProxy::UpdateTransform() { | 575 void WebPluginProxy::UpdateTransform() { |
561 NOTIMPLEMENTED(); | |
562 } | 576 } |
563 | 577 |
564 void WebPluginProxy::SetWindowlessBuffer( | 578 void WebPluginProxy::SetWindowlessBuffer( |
565 const TransportDIB::Handle& windowless_buffer, | 579 const TransportDIB::Handle& windowless_buffer, |
566 const TransportDIB::Handle& background_buffer) { | 580 const TransportDIB::Handle& background_buffer) { |
567 NOTIMPLEMENTED(); | 581 int width = delegate_->GetRect().width(); |
| 582 int height = delegate_->GetRect().height(); |
| 583 windowless_dib_.reset(TransportDIB::Map(windowless_buffer)); |
| 584 windowless_canvas_.reset(windowless_dib_->GetPlatformCanvas(width, height)); |
| 585 background_dib_.reset(TransportDIB::Map(background_buffer)); |
| 586 if (background_dib_.get()) { |
| 587 background_canvas_.reset(background_dib_->GetPlatformCanvas(width, height)); |
| 588 } else { |
| 589 background_canvas_.reset(); |
| 590 } |
568 } | 591 } |
569 #endif | 592 #endif |
570 | 593 |
571 void WebPluginProxy::CancelDocumentLoad() { | 594 void WebPluginProxy::CancelDocumentLoad() { |
572 Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); | 595 Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); |
573 } | 596 } |
574 | 597 |
575 void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, | 598 void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, |
576 const char* range_info, | 599 const char* range_info, |
577 intptr_t existing_stream, | 600 intptr_t existing_stream, |
(...skipping 22 matching lines...) Expand all Loading... |
600 while (index != resource_clients_.end()) { | 623 while (index != resource_clients_.end()) { |
601 WebPluginResourceClient* client = (*index).second; | 624 WebPluginResourceClient* client = (*index).second; |
602 | 625 |
603 if (client == resource_client) { | 626 if (client == resource_client) { |
604 resource_clients_.erase(index++); | 627 resource_clients_.erase(index++); |
605 } else { | 628 } else { |
606 index++; | 629 index++; |
607 } | 630 } |
608 } | 631 } |
609 } | 632 } |
OLD | NEW |