OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 SkIntToScalar(image_data_->height())); | 541 SkIntToScalar(image_data_->height())); |
542 canvas->clipRect(image_data_rect, SkRegion::kDifference_Op); | 542 canvas->clipRect(image_data_rect, SkRegion::kDifference_Op); |
543 | 543 |
544 SkPaint paint; | 544 SkPaint paint; |
545 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 545 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
546 paint.setColor(SK_ColorWHITE); | 546 paint.setColor(SK_ColorWHITE); |
547 canvas->drawRect(sk_plugin_rect, paint); | 547 canvas->drawRect(sk_plugin_rect, paint); |
548 canvas->restore(); | 548 canvas->restore(); |
549 } | 549 } |
550 | 550 |
| 551 SkBitmap image; |
| 552 // Copy to device independent bitmap when target canvas doesn't support |
| 553 // platform paint. |
| 554 if (!skia::SupportsPlatformPaint(canvas)) |
| 555 backing_bitmap.copyTo(&image, SkBitmap::kARGB_8888_Config); |
| 556 else |
| 557 image = backing_bitmap; |
| 558 |
551 SkPaint paint; | 559 SkPaint paint; |
552 if (is_always_opaque_) { | 560 if (is_always_opaque_) { |
553 // When we know the device is opaque, we can disable blending for slightly | 561 // When we know the device is opaque, we can disable blending for slightly |
554 // more optimized painting. | 562 // more optimized painting. |
555 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 563 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
556 } | 564 } |
557 canvas->drawBitmap(backing_bitmap, | 565 canvas->drawBitmap(image, |
558 SkIntToScalar(plugin_rect.x()), | 566 SkIntToScalar(plugin_rect.x()), |
559 SkIntToScalar(plugin_rect.y()), | 567 SkIntToScalar(plugin_rect.y()), |
560 &paint); | 568 &paint); |
561 canvas->restore(); | 569 canvas->restore(); |
562 #endif | 570 #endif |
563 } | 571 } |
564 | 572 |
565 void PPB_Graphics2D_Impl::ViewWillInitiatePaint() { | 573 void PPB_Graphics2D_Impl::ViewWillInitiatePaint() { |
566 // Move any "unpainted" callback to the painted state. See | 574 // Move any "unpainted" callback to the painted state. See |
567 // |unpainted_flush_callback_| in the header for more. | 575 // |unpainted_flush_callback_| in the header for more. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 680 } |
673 | 681 |
674 bool PPB_Graphics2D_Impl::HasPendingFlush() const { | 682 bool PPB_Graphics2D_Impl::HasPendingFlush() const { |
675 return !unpainted_flush_callback_.is_null() || | 683 return !unpainted_flush_callback_.is_null() || |
676 !painted_flush_callback_.is_null() || | 684 !painted_flush_callback_.is_null() || |
677 offscreen_flush_pending_; | 685 offscreen_flush_pending_; |
678 } | 686 } |
679 | 687 |
680 } // namespace ppapi | 688 } // namespace ppapi |
681 } // namespace webkit | 689 } // namespace webkit |
OLD | NEW |