| 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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 SkPaint copy_paint; | 521 SkPaint copy_paint; |
| 522 copy_paint.setBlendMode(SkBlendMode::kSrc); | 522 copy_paint.setBlendMode(SkBlendMode::kSrc); |
| 523 surface_->draw(temp_hibernation_surface->getCanvas(), 0, 0, | 523 surface_->draw(temp_hibernation_surface->getCanvas(), 0, 0, |
| 524 ©_paint); // GPU readback | 524 ©_paint); // GPU readback |
| 525 hibernation_image_ = temp_hibernation_surface->makeImageSnapshot(); | 525 hibernation_image_ = temp_hibernation_surface->makeImageSnapshot(); |
| 526 ResetSurface(); | 526 ResetSurface(); |
| 527 layer_->ClearTexture(); | 527 layer_->ClearTexture(); |
| 528 #if USE_IOSURFACE_FOR_2D_CANVAS | 528 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 529 ClearCHROMIUMImageCache(); | 529 ClearCHROMIUMImageCache(); |
| 530 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 530 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 531 // shouldBeDirectComposited() may have changed. |
| 532 if (image_buffer_) |
| 533 image_buffer_->SetNeedsCompositingUpdate(); |
| 531 logger_->DidStartHibernating(); | 534 logger_->DidStartHibernating(); |
| 532 } | 535 } |
| 533 | 536 |
| 534 sk_sp<SkColorSpace> Canvas2DLayerBridge::SkSurfaceColorSpace() const { | 537 sk_sp<SkColorSpace> Canvas2DLayerBridge::SkSurfaceColorSpace() const { |
| 535 if (sk_surfaces_use_color_space_) | 538 if (sk_surfaces_use_color_space_) |
| 536 return color_space_.ToSkColorSpace(); | 539 return color_space_.ToSkColorSpace(); |
| 537 return nullptr; | 540 return nullptr; |
| 538 } | 541 } |
| 539 | 542 |
| 540 void Canvas2DLayerBridge::ReportSurfaceCreationFailure() { | 543 void Canvas2DLayerBridge::ReportSurfaceCreationFailure() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 else | 603 else |
| 601 logger_->ReportHibernationEvent(kHibernationEndedWithFallbackToSW); | 604 logger_->ReportHibernationEvent(kHibernationEndedWithFallbackToSW); |
| 602 } | 605 } |
| 603 | 606 |
| 604 SkPaint copy_paint; | 607 SkPaint copy_paint; |
| 605 copy_paint.setBlendMode(SkBlendMode::kSrc); | 608 copy_paint.setBlendMode(SkBlendMode::kSrc); |
| 606 surface_->getCanvas()->drawImage(hibernation_image_.get(), 0, 0, | 609 surface_->getCanvas()->drawImage(hibernation_image_.get(), 0, 0, |
| 607 ©_paint); | 610 ©_paint); |
| 608 hibernation_image_.reset(); | 611 hibernation_image_.reset(); |
| 609 | 612 |
| 610 if (image_buffer_) | 613 if (image_buffer_) { |
| 611 image_buffer_->UpdateGPUMemoryUsage(); | 614 image_buffer_->UpdateGPUMemoryUsage(); |
| 612 | 615 |
| 613 if (image_buffer_ && !is_deferral_enabled_) | 616 if (!is_deferral_enabled_) |
| 614 image_buffer_->ResetCanvas(surface_paint_canvas_.get()); | 617 image_buffer_->ResetCanvas(surface_paint_canvas_.get()); |
| 618 |
| 619 // shouldBeDirectComposited() may have changed. |
| 620 image_buffer_->SetNeedsCompositingUpdate(); |
| 621 } |
| 615 } | 622 } |
| 616 | 623 |
| 617 return surface_.get(); | 624 return surface_.get(); |
| 618 } | 625 } |
| 619 | 626 |
| 620 PaintCanvas* Canvas2DLayerBridge::Canvas() { | 627 PaintCanvas* Canvas2DLayerBridge::Canvas() { |
| 621 if (!is_deferral_enabled_) { | 628 if (!is_deferral_enabled_) { |
| 622 GetOrCreateSurface(); | 629 GetOrCreateSurface(); |
| 623 return surface_paint_canvas_.get(); | 630 return surface_paint_canvas_.get(); |
| 624 } | 631 } |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 default; | 1137 default; |
| 1131 | 1138 |
| 1132 void Canvas2DLayerBridge::Logger::ReportHibernationEvent( | 1139 void Canvas2DLayerBridge::Logger::ReportHibernationEvent( |
| 1133 HibernationEvent event) { | 1140 HibernationEvent event) { |
| 1134 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernation_histogram, | 1141 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernation_histogram, |
| 1135 ("Canvas.HibernationEvents", kHibernationEventCount)); | 1142 ("Canvas.HibernationEvents", kHibernationEventCount)); |
| 1136 hibernation_histogram.Count(event); | 1143 hibernation_histogram.Count(event); |
| 1137 } | 1144 } |
| 1138 | 1145 |
| 1139 } // namespace blink | 1146 } // namespace blink |
| OLD | NEW |