Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: content/browser/compositor/delegated_frame_host.cc

Issue 1582053002: Implement webview.captureVisibleRegion() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move captureVisibleRegion() to experimental API. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/compositor/delegated_frame_host.h" 5 #include "content/browser/compositor/delegated_frame_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 void DelegatedFrameHost::EvictDelegatedFrame() { 585 void DelegatedFrameHost::EvictDelegatedFrame() {
586 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); 586 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent();
587 frame_provider_ = NULL; 587 frame_provider_ = NULL;
588 if (!surface_id_.is_null()) { 588 if (!surface_id_.is_null()) {
589 surface_factory_->Destroy(surface_id_); 589 surface_factory_->Destroy(surface_id_);
590 surface_id_ = cc::SurfaceId(); 590 surface_id_ = cc::SurfaceId();
591 } 591 }
592 delegated_frame_evictor_->DiscardedFrame(); 592 delegated_frame_evictor_->DiscardedFrame();
593 } 593 }
594 594
595 // TODO(wjmaclean): Remove this and get from readback_request_helpers.h instead.
Charlie Reis 2016/01/19 22:45:36 Normally I'd be fine with keeping this CL small an
wjmaclean 2016/01/20 15:32:36 I was mostly hoping to limit the damage if somethi
595 // static 596 // static
596 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( 597 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult(
597 const gfx::Size& dst_size_in_pixel, 598 const gfx::Size& dst_size_in_pixel,
598 const SkColorType color_type, 599 const SkColorType color_type,
599 const ReadbackRequestCallback& callback, 600 const ReadbackRequestCallback& callback,
600 scoped_ptr<cc::CopyOutputResult> result) { 601 scoped_ptr<cc::CopyOutputResult> result) {
601 if (result->IsEmpty() || result->size().IsEmpty()) { 602 if (result->IsEmpty() || result->size().IsEmpty()) {
602 callback.Run(SkBitmap(), content::READBACK_FAILED); 603 callback.Run(SkBitmap(), content::READBACK_FAILED);
603 return; 604 return;
604 } 605 }
(...skipping 10 matching lines...) Expand all
615 std::move(result)); 616 std::move(result));
616 return; 617 return;
617 } 618 }
618 619
619 DCHECK(result->HasBitmap()); 620 DCHECK(result->HasBitmap());
620 // Software path 621 // Software path
621 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, 622 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
622 std::move(result)); 623 std::move(result));
623 } 624 }
624 625
626 // TODO(wjmaclean): Remove this and get from readback_request_helpers.h instead.
625 static void CopyFromCompositingSurfaceFinished( 627 static void CopyFromCompositingSurfaceFinished(
626 const ReadbackRequestCallback& callback, 628 const ReadbackRequestCallback& callback,
627 scoped_ptr<cc::SingleReleaseCallback> release_callback, 629 scoped_ptr<cc::SingleReleaseCallback> release_callback,
628 scoped_ptr<SkBitmap> bitmap, 630 scoped_ptr<SkBitmap> bitmap,
629 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 631 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
630 bool result) { 632 bool result) {
631 bitmap_pixels_lock.reset(); 633 bitmap_pixels_lock.reset();
632 634
633 gpu::SyncToken sync_token; 635 gpu::SyncToken sync_token;
634 if (result) { 636 if (result) {
635 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); 637 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
636 if (gl_helper) 638 if (gl_helper)
637 gl_helper->GenerateSyncToken(&sync_token); 639 gl_helper->GenerateSyncToken(&sync_token);
638 } 640 }
639 const bool lost_resource = !sync_token.HasData(); 641 const bool lost_resource = !sync_token.HasData();
640 release_callback->Run(sync_token, lost_resource); 642 release_callback->Run(sync_token, lost_resource);
641 643
642 callback.Run(*bitmap, 644 callback.Run(*bitmap,
643 result ? content::READBACK_SUCCESS : content::READBACK_FAILED); 645 result ? content::READBACK_SUCCESS : content::READBACK_FAILED);
644 } 646 }
645 647
648 // TODO(wjmaclean): Remove this and get from readback_request_helpers.h instead.
646 // static 649 // static
647 void DelegatedFrameHost::PrepareTextureCopyOutputResult( 650 void DelegatedFrameHost::PrepareTextureCopyOutputResult(
648 const gfx::Size& dst_size_in_pixel, 651 const gfx::Size& dst_size_in_pixel,
649 const SkColorType color_type, 652 const SkColorType color_type,
650 const ReadbackRequestCallback& callback, 653 const ReadbackRequestCallback& callback,
651 scoped_ptr<cc::CopyOutputResult> result) { 654 scoped_ptr<cc::CopyOutputResult> result) {
652 DCHECK(result->HasTexture()); 655 DCHECK(result->HasTexture());
653 base::ScopedClosureRunner scoped_callback_runner( 656 base::ScopedClosureRunner scoped_callback_runner(
654 base::Bind(callback, SkBitmap(), content::READBACK_FAILED)); 657 base::Bind(callback, SkBitmap(), content::READBACK_FAILED));
655 658
(...skipping 27 matching lines...) Expand all
683 686
684 gl_helper->CropScaleReadbackAndCleanMailbox( 687 gl_helper->CropScaleReadbackAndCleanMailbox(
685 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), 688 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(),
686 gfx::Rect(result->size()), dst_size_in_pixel, pixels, color_type, 689 gfx::Rect(result->size()), dst_size_in_pixel, pixels, color_type,
687 base::Bind(&CopyFromCompositingSurfaceFinished, callback, 690 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
688 base::Passed(&release_callback), base::Passed(&bitmap), 691 base::Passed(&release_callback), base::Passed(&bitmap),
689 base::Passed(&bitmap_pixels_lock)), 692 base::Passed(&bitmap_pixels_lock)),
690 GLHelper::SCALER_QUALITY_GOOD); 693 GLHelper::SCALER_QUALITY_GOOD);
691 } 694 }
692 695
696 // TODO(wjmaclean): Remove this and get from readback_request_helpers.h instead.
693 // static 697 // static
694 void DelegatedFrameHost::PrepareBitmapCopyOutputResult( 698 void DelegatedFrameHost::PrepareBitmapCopyOutputResult(
695 const gfx::Size& dst_size_in_pixel, 699 const gfx::Size& dst_size_in_pixel,
696 const SkColorType preferred_color_type, 700 const SkColorType preferred_color_type,
697 const ReadbackRequestCallback& callback, 701 const ReadbackRequestCallback& callback,
698 scoped_ptr<cc::CopyOutputResult> result) { 702 scoped_ptr<cc::CopyOutputResult> result) {
699 SkColorType color_type = preferred_color_type; 703 SkColorType color_type = preferred_color_type;
700 if (color_type != kN32_SkColorType && color_type != kAlpha_8_SkColorType) { 704 if (color_type != kN32_SkColorType && color_type != kAlpha_8_SkColorType) {
701 // Switch back to default colortype if format not supported. 705 // Switch back to default colortype if format not supported.
702 color_type = kN32_SkColorType; 706 color_type = kN32_SkColorType;
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1046
1043 void DelegatedFrameHost::LockResources() { 1047 void DelegatedFrameHost::LockResources() {
1044 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 1048 DCHECK(frame_provider_.get() || !surface_id_.is_null());
1045 delegated_frame_evictor_->LockFrame(); 1049 delegated_frame_evictor_->LockFrame();
1046 } 1050 }
1047 1051
1048 void DelegatedFrameHost::RequestCopyOfOutput( 1052 void DelegatedFrameHost::RequestCopyOfOutput(
1049 scoped_ptr<cc::CopyOutputRequest> request) { 1053 scoped_ptr<cc::CopyOutputRequest> request) {
1050 if (!request_copy_of_output_callback_for_testing_.is_null()) 1054 if (!request_copy_of_output_callback_for_testing_.is_null())
1051 request_copy_of_output_callback_for_testing_.Run(std::move(request)); 1055 request_copy_of_output_callback_for_testing_.Run(std::move(request));
1052 else 1056 else {
1053 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( 1057 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(
1054 std::move(request)); 1058 std::move(request));
1059 }
1055 } 1060 }
1056 1061
1057 void DelegatedFrameHost::UnlockResources() { 1062 void DelegatedFrameHost::UnlockResources() {
1058 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 1063 DCHECK(frame_provider_.get() || !surface_id_.is_null());
1059 delegated_frame_evictor_->UnlockFrame(); 1064 delegated_frame_evictor_->UnlockFrame();
1060 } 1065 }
1061 1066
1062 //////////////////////////////////////////////////////////////////////////////// 1067 ////////////////////////////////////////////////////////////////////////////////
1063 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation: 1068 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation:
1064 1069
(...skipping 11 matching lines...) Expand all
1076 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1081 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1077 new_layer->SetShowSurface( 1082 new_layer->SetShowSurface(
1078 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1083 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1079 base::Bind(&RequireCallback, base::Unretained(manager)), 1084 base::Bind(&RequireCallback, base::Unretained(manager)),
1080 current_surface_size_, current_scale_factor_, 1085 current_surface_size_, current_scale_factor_,
1081 current_frame_size_in_dip_); 1086 current_frame_size_in_dip_);
1082 } 1087 }
1083 } 1088 }
1084 1089
1085 } // namespace content 1090 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698