| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 y + image_resource->height() }; | 391 y + image_resource->height() }; |
| 392 SkRect dest_rect = { SkIntToScalar(0), | 392 SkRect dest_rect = { SkIntToScalar(0), |
| 393 SkIntToScalar(0), | 393 SkIntToScalar(0), |
| 394 SkIntToScalar(image_resource->width()), | 394 SkIntToScalar(image_resource->width()), |
| 395 SkIntToScalar(image_resource->height()) }; | 395 SkIntToScalar(image_resource->height()) }; |
| 396 | 396 |
| 397 if (image_resource->format() != image_data_->format()) { | 397 if (image_resource->format() != image_data_->format()) { |
| 398 // Convert the image data if the format does not match. | 398 // Convert the image data if the format does not match. |
| 399 ConvertImageData(image_data_, src_irect, image_resource, dest_rect); | 399 ConvertImageData(image_data_, src_irect, image_resource, dest_rect); |
| 400 } else { | 400 } else { |
| 401 skia::PlatformCanvas* dest_canvas = image_resource->mapped_canvas(); | 401 skia::PlatformCanvas* dest_canvas = image_resource->GetPlatformCanvas(); |
| 402 | 402 |
| 403 // We want to replace the contents of the bitmap rather than blend. | 403 // We want to replace the contents of the bitmap rather than blend. |
| 404 SkPaint paint; | 404 SkPaint paint; |
| 405 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 405 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 406 dest_canvas->drawBitmapRect(*image_data_->GetMappedBitmap(), | 406 dest_canvas->drawBitmapRect(*image_data_->GetMappedBitmap(), |
| 407 &src_irect, dest_rect, &paint); | 407 &src_irect, dest_rect, &paint); |
| 408 } | 408 } |
| 409 return true; | 409 return true; |
| 410 } | 410 } |
| 411 | 411 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 SkRect dest_rect = { SkIntToScalar(invalidated_rect->x()), | 576 SkRect dest_rect = { SkIntToScalar(invalidated_rect->x()), |
| 577 SkIntToScalar(invalidated_rect->y()), | 577 SkIntToScalar(invalidated_rect->y()), |
| 578 SkIntToScalar(invalidated_rect->right()), | 578 SkIntToScalar(invalidated_rect->right()), |
| 579 SkIntToScalar(invalidated_rect->bottom()) }; | 579 SkIntToScalar(invalidated_rect->bottom()) }; |
| 580 | 580 |
| 581 if (image->format() != image_data_->format()) { | 581 if (image->format() != image_data_->format()) { |
| 582 // Convert the image data if the format does not match. | 582 // Convert the image data if the format does not match. |
| 583 ConvertImageData(image, src_irect, image_data_, dest_rect); | 583 ConvertImageData(image, src_irect, image_data_, dest_rect); |
| 584 } else { | 584 } else { |
| 585 // We're guaranteed to have a mapped canvas since we mapped it in Init(). | 585 // We're guaranteed to have a mapped canvas since we mapped it in Init(). |
| 586 skia::PlatformCanvas* backing_canvas = image_data_->mapped_canvas(); | 586 skia::PlatformCanvas* backing_canvas = image_data_->GetPlatformCanvas(); |
| 587 | 587 |
| 588 // We want to replace the contents of the bitmap rather than blend. | 588 // We want to replace the contents of the bitmap rather than blend. |
| 589 SkPaint paint; | 589 SkPaint paint; |
| 590 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 590 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 591 backing_canvas->drawBitmapRect(*image->GetMappedBitmap(), | 591 backing_canvas->drawBitmapRect(*image->GetMappedBitmap(), |
| 592 &src_irect, dest_rect, &paint); | 592 &src_irect, dest_rect, &paint); |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip, | 596 void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip, |
| 597 int dx, int dy, | 597 int dx, int dy, |
| 598 gfx::Rect* invalidated_rect) { | 598 gfx::Rect* invalidated_rect) { |
| 599 gfx::ScrollCanvas(image_data_->mapped_canvas(), | 599 gfx::ScrollCanvas(image_data_->GetPlatformCanvas(), |
| 600 clip, gfx::Point(dx, dy)); | 600 clip, gfx::Point(dx, dy)); |
| 601 *invalidated_rect = clip; | 601 *invalidated_rect = clip; |
| 602 } | 602 } |
| 603 | 603 |
| 604 void PPB_Graphics2D_Impl::ExecuteReplaceContents(PPB_ImageData_Impl* image, | 604 void PPB_Graphics2D_Impl::ExecuteReplaceContents(PPB_ImageData_Impl* image, |
| 605 gfx::Rect* invalidated_rect) { | 605 gfx::Rect* invalidated_rect) { |
| 606 if (image->format() != image_data_->format()) { | 606 if (image->format() != image_data_->format()) { |
| 607 DCHECK(image->width() == image_data_->width() && | 607 DCHECK(image->width() == image_data_->width() && |
| 608 image->height() == image_data_->height()); | 608 image->height() == image_data_->height()); |
| 609 // Convert the image data if the format does not match. | 609 // Convert the image data if the format does not match. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool PPB_Graphics2D_Impl::HasPendingFlush() const { | 649 bool PPB_Graphics2D_Impl::HasPendingFlush() const { |
| 650 return !unpainted_flush_callback_.is_null() || | 650 return !unpainted_flush_callback_.is_null() || |
| 651 !painted_flush_callback_.is_null() || | 651 !painted_flush_callback_.is_null() || |
| 652 offscreen_flush_pending_; | 652 offscreen_flush_pending_; |
| 653 } | 653 } |
| 654 | 654 |
| 655 } // namespace ppapi | 655 } // namespace ppapi |
| 656 } // namespace webkit | 656 } // namespace webkit |
| OLD | NEW |