| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 SkPaint copy_paint; | 520 SkPaint copy_paint; |
| 521 copy_paint.setBlendMode(SkBlendMode::kSrc); | 521 copy_paint.setBlendMode(SkBlendMode::kSrc); |
| 522 surface_->draw(temp_hibernation_surface->getCanvas(), 0, 0, | 522 surface_->draw(temp_hibernation_surface->getCanvas(), 0, 0, |
| 523 ©_paint); // GPU readback | 523 ©_paint); // GPU readback |
| 524 hibernation_image_ = temp_hibernation_surface->makeImageSnapshot(); | 524 hibernation_image_ = temp_hibernation_surface->makeImageSnapshot(); |
| 525 ResetSurface(); | 525 ResetSurface(); |
| 526 layer_->ClearTexture(); | 526 layer_->ClearTexture(); |
| 527 #if USE_IOSURFACE_FOR_2D_CANVAS | 527 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 528 ClearCHROMIUMImageCache(); | 528 ClearCHROMIUMImageCache(); |
| 529 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 529 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 530 // shouldBeDirectComposited() may have changed. |
| 531 if (image_buffer_) |
| 532 image_buffer_->SetNeedsCompositingUpdate(); |
| 530 logger_->DidStartHibernating(); | 533 logger_->DidStartHibernating(); |
| 531 } | 534 } |
| 532 | 535 |
| 533 sk_sp<SkColorSpace> Canvas2DLayerBridge::SkSurfaceColorSpace() const { | 536 sk_sp<SkColorSpace> Canvas2DLayerBridge::SkSurfaceColorSpace() const { |
| 534 if (sk_surfaces_use_color_space_) | 537 if (sk_surfaces_use_color_space_) |
| 535 return color_space_.ToSkColorSpace(); | 538 return color_space_.ToSkColorSpace(); |
| 536 return nullptr; | 539 return nullptr; |
| 537 } | 540 } |
| 538 | 541 |
| 539 void Canvas2DLayerBridge::ReportSurfaceCreationFailure() { | 542 void Canvas2DLayerBridge::ReportSurfaceCreationFailure() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 else | 602 else |
| 600 logger_->ReportHibernationEvent(kHibernationEndedWithFallbackToSW); | 603 logger_->ReportHibernationEvent(kHibernationEndedWithFallbackToSW); |
| 601 } | 604 } |
| 602 | 605 |
| 603 SkPaint copy_paint; | 606 SkPaint copy_paint; |
| 604 copy_paint.setBlendMode(SkBlendMode::kSrc); | 607 copy_paint.setBlendMode(SkBlendMode::kSrc); |
| 605 surface_->getCanvas()->drawImage(hibernation_image_.get(), 0, 0, | 608 surface_->getCanvas()->drawImage(hibernation_image_.get(), 0, 0, |
| 606 ©_paint); | 609 ©_paint); |
| 607 hibernation_image_.reset(); | 610 hibernation_image_.reset(); |
| 608 | 611 |
| 609 if (image_buffer_) | 612 if (image_buffer_) { |
| 610 image_buffer_->UpdateGPUMemoryUsage(); | 613 image_buffer_->UpdateGPUMemoryUsage(); |
| 611 | 614 |
| 612 if (image_buffer_ && !is_deferral_enabled_) | 615 if (!is_deferral_enabled_) |
| 613 image_buffer_->ResetCanvas(surface_paint_canvas_.get()); | 616 image_buffer_->ResetCanvas(surface_paint_canvas_.get()); |
| 617 |
| 618 // shouldBeDirectComposited() may have changed. |
| 619 image_buffer_->SetNeedsCompositingUpdate(); |
| 620 } |
| 614 } | 621 } |
| 615 | 622 |
| 616 return surface_.get(); | 623 return surface_.get(); |
| 617 } | 624 } |
| 618 | 625 |
| 619 PaintCanvas* Canvas2DLayerBridge::Canvas() { | 626 PaintCanvas* Canvas2DLayerBridge::Canvas() { |
| 620 if (!is_deferral_enabled_) { | 627 if (!is_deferral_enabled_) { |
| 621 GetOrCreateSurface(); | 628 GetOrCreateSurface(); |
| 622 return surface_paint_canvas_.get(); | 629 return surface_paint_canvas_.get(); |
| 623 } | 630 } |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 default; | 1124 default; |
| 1118 | 1125 |
| 1119 void Canvas2DLayerBridge::Logger::ReportHibernationEvent( | 1126 void Canvas2DLayerBridge::Logger::ReportHibernationEvent( |
| 1120 HibernationEvent event) { | 1127 HibernationEvent event) { |
| 1121 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernation_histogram, | 1128 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernation_histogram, |
| 1122 ("Canvas.HibernationEvents", kHibernationEventCount)); | 1129 ("Canvas.HibernationEvents", kHibernationEventCount)); |
| 1123 hibernation_histogram.Count(event); | 1130 hibernation_histogram.Count(event); |
| 1124 } | 1131 } |
| 1125 | 1132 |
| 1126 } // namespace blink | 1133 } // namespace blink |
| OLD | NEW |