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

Side by Side Diff: components/exo/surface.cc

Issue 2032173002: exo: Allow updating cc::Surface viewport and crop state independently. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « components/exo/surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/surface.h" 5 #include "components/exo/surface.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 DCHECK(ListContainsEntry(pending_sub_surfaces_, sub_surface)); 382 DCHECK(ListContainsEntry(pending_sub_surfaces_, sub_surface));
383 pending_sub_surfaces_.splice( 383 pending_sub_surfaces_.splice(
384 sibling_it, pending_sub_surfaces_, 384 sibling_it, pending_sub_surfaces_,
385 FindListEntry(pending_sub_surfaces_, sub_surface)); 385 FindListEntry(pending_sub_surfaces_, sub_surface));
386 } 386 }
387 387
388 void Surface::SetViewport(const gfx::Size& viewport) { 388 void Surface::SetViewport(const gfx::Size& viewport) {
389 TRACE_EVENT1("exo", "Surface::SetViewport", "viewport", viewport.ToString()); 389 TRACE_EVENT1("exo", "Surface::SetViewport", "viewport", viewport.ToString());
390 390
391 if (pending_viewport_ == viewport)
392 return;
393
391 pending_viewport_ = viewport; 394 pending_viewport_ = viewport;
395 changed_viewport_or_crop_ = true;
392 } 396 }
393 397
394 void Surface::SetCrop(const gfx::RectF& crop) { 398 void Surface::SetCrop(const gfx::RectF& crop) {
395 TRACE_EVENT1("exo", "Surface::SetCrop", "crop", crop.ToString()); 399 TRACE_EVENT1("exo", "Surface::SetCrop", "crop", crop.ToString());
396 400
401 if (pending_crop_ == crop)
402 return;
403
397 pending_crop_ = crop; 404 pending_crop_ = crop;
405 changed_viewport_or_crop_ = true;
398 } 406 }
399 407
400 void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) { 408 void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) {
401 TRACE_EVENT1("exo", "Surface::SetOnlyVisibleOnSecureOutput", 409 TRACE_EVENT1("exo", "Surface::SetOnlyVisibleOnSecureOutput",
402 "only_visible_on_secure_output", only_visible_on_secure_output); 410 "only_visible_on_secure_output", only_visible_on_secure_output);
403 411
404 pending_only_visible_on_secure_output_ = only_visible_on_secure_output; 412 pending_only_visible_on_secure_output_ = only_visible_on_secure_output;
405 } 413 }
406 414
407 void Surface::SetBlendMode(SkXfermode::Mode blend_mode) { 415 void Surface::SetBlendMode(SkXfermode::Mode blend_mode) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // fills-bounds-opaquely. 513 // fills-bounds-opaquely.
506 layer()->SetFillsBoundsOpaquely( 514 layer()->SetFillsBoundsOpaquely(
507 pending_blend_mode_ == SkXfermode::kSrc_Mode || 515 pending_blend_mode_ == SkXfermode::kSrc_Mode ||
508 pending_opaque_region_.contains( 516 pending_opaque_region_.contains(
509 gfx::RectToSkIRect(gfx::Rect(layer()->size())))); 517 gfx::RectToSkIRect(gfx::Rect(layer()->size()))));
510 } 518 }
511 519
512 void Surface::CommitSurfaceContents() { 520 void Surface::CommitSurfaceContents() {
513 // We update contents if Attach() has been called since last commit. 521 // We update contents if Attach() has been called since last commit.
514 if (has_pending_contents_) { 522 if (has_pending_contents_) {
515 has_pending_contents_ = false;
516
517 current_buffer_ = pending_buffer_; 523 current_buffer_ = pending_buffer_;
518 pending_buffer_.reset(); 524 pending_buffer_.reset();
519 525
520 bool secure_output_only = pending_only_visible_on_secure_output_; 526 if (current_buffer_) {
521 pending_only_visible_on_secure_output_ = false; 527 std::unique_ptr<cc::SingleReleaseCallback>
528 texture_mailbox_release_callback;
522 529
523 cc::TextureMailbox texture_mailbox; 530 cc::TextureMailbox texture_mailbox;
524 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback;
525 if (current_buffer_) {
526 texture_mailbox_release_callback = current_buffer_->ProduceTextureMailbox( 531 texture_mailbox_release_callback = current_buffer_->ProduceTextureMailbox(
527 &texture_mailbox, secure_output_only, false); 532 &texture_mailbox, pending_only_visible_on_secure_output_, false);
533 cc::TransferableResource resource;
534 resource.id = next_resource_id_++;
535 resource.format = cc::RGBA_8888;
536 resource.filter =
537 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR;
538 resource.size = texture_mailbox.size_in_pixels();
539 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(),
540 texture_mailbox.sync_token(),
541 texture_mailbox.target());
542 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate();
543
544 factory_owner_->release_callbacks_[resource.id] = std::make_pair(
545 factory_owner_, std::move(texture_mailbox_release_callback));
546 current_resource_ = resource;
547 } else {
548 current_resource_.id = 0;
549 current_resource_.size = gfx::Size();
528 } 550 }
551 }
552
553 if (has_pending_contents_ || changed_viewport_or_crop_) {
reveman 2016/06/03 19:06:51 Do we need this if statement and the new changed_v
554 has_pending_contents_ = false;
555 changed_viewport_or_crop_ = false;
529 556
530 cc::SurfaceId old_surface_id = surface_id_; 557 cc::SurfaceId old_surface_id = surface_id_;
531 surface_id_ = factory_owner_->id_allocator_->GenerateId(); 558 surface_id_ = factory_owner_->id_allocator_->GenerateId();
532 factory_owner_->surface_factory_->Create(surface_id_); 559 factory_owner_->surface_factory_->Create(surface_id_);
533 560
534 gfx::Size buffer_size = texture_mailbox.size_in_pixels(); 561 gfx::Size buffer_size = current_resource_.size;
535 gfx::SizeF scaled_buffer_size( 562 gfx::SizeF scaled_buffer_size(
536 gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / pending_buffer_scale_)); 563 gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / pending_buffer_scale_));
537 564
538 gfx::Size layer_size; // Size of the output layer, in DIP. 565 gfx::Size layer_size; // Size of the output layer, in DIP.
539 if (!pending_viewport_.IsEmpty()) { 566 if (!pending_viewport_.IsEmpty()) {
540 layer_size = pending_viewport_; 567 layer_size = pending_viewport_;
541 } else if (!pending_crop_.IsEmpty()) { 568 } else if (!pending_crop_.IsEmpty()) {
542 DLOG_IF(WARNING, !gfx::IsExpressibleAsInt(pending_crop_.width()) || 569 DLOG_IF(WARNING, !gfx::IsExpressibleAsInt(pending_crop_.width()) ||
543 !gfx::IsExpressibleAsInt(pending_crop_.height())) 570 !gfx::IsExpressibleAsInt(pending_crop_.height()))
544 << "Crop rectangle size (" << pending_crop_.size().ToString() 571 << "Crop rectangle size (" << pending_crop_.size().ToString()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 render_pass->CreateAndAppendSharedQuadState(); 605 render_pass->CreateAndAppendSharedQuadState();
579 quad_state->quad_layer_bounds = contents_surface_size; 606 quad_state->quad_layer_bounds = contents_surface_size;
580 quad_state->visible_quad_layer_rect = quad_rect; 607 quad_state->visible_quad_layer_rect = quad_rect;
581 quad_state->opacity = alpha_; 608 quad_state->opacity = alpha_;
582 alpha_ = pending_alpha_; 609 alpha_ = pending_alpha_;
583 610
584 bool frame_is_opaque = false; 611 bool frame_is_opaque = false;
585 612
586 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( 613 std::unique_ptr<cc::DelegatedFrameData> delegated_frame(
587 new cc::DelegatedFrameData); 614 new cc::DelegatedFrameData);
588 if (texture_mailbox_release_callback) { 615 if (current_resource_.id) {
589 cc::TransferableResource resource;
590 resource.id = next_resource_id_++;
591 resource.format = cc::RGBA_8888;
592 resource.filter =
593 texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR;
594 resource.size = texture_mailbox.size_in_pixels();
595 resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(),
596 texture_mailbox.sync_token(),
597 texture_mailbox.target());
598 resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate();
599
600 cc::TextureDrawQuad* texture_quad = 616 cc::TextureDrawQuad* texture_quad =
601 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 617 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
602 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; 618 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0};
603 gfx::Rect opaque_rect; 619 gfx::Rect opaque_rect;
604 frame_is_opaque = 620 frame_is_opaque =
605 pending_blend_mode_ == SkXfermode::kSrc_Mode || 621 pending_blend_mode_ == SkXfermode::kSrc_Mode ||
606 pending_opaque_region_.contains(gfx::RectToSkIRect(quad_rect)); 622 pending_opaque_region_.contains(gfx::RectToSkIRect(quad_rect));
607 if (frame_is_opaque) { 623 if (frame_is_opaque) {
608 opaque_rect = quad_rect; 624 opaque_rect = quad_rect;
609 } else if (pending_opaque_region_.isRect()) { 625 } else if (pending_opaque_region_.isRect()) {
610 opaque_rect = gfx::SkIRectToRect(pending_opaque_region_.getBounds()); 626 opaque_rect = gfx::SkIRectToRect(pending_opaque_region_.getBounds());
611 } 627 }
612 628
613 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, 629 texture_quad->SetNew(
614 resource.id, true, uv_top_left, uv_bottom_right, 630 quad_state, quad_rect, opaque_rect, quad_rect, current_resource_.id,
615 SK_ColorTRANSPARENT, vertex_opacity, false, false, 631 true, uv_top_left, uv_bottom_right, SK_ColorTRANSPARENT,
616 secure_output_only); 632 vertex_opacity, false, false, pending_only_visible_on_secure_output_);
617 633 delegated_frame->resource_list.push_back(current_resource_);
618 factory_owner_->release_callbacks_[resource.id] = std::make_pair(
619 factory_owner_, std::move(texture_mailbox_release_callback));
620 delegated_frame->resource_list.push_back(resource);
621 } else { 634 } else {
622 cc::SolidColorDrawQuad* solid_quad = 635 cc::SolidColorDrawQuad* solid_quad =
623 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); 636 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
624 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, 637 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK,
625 false); 638 false);
626 frame_is_opaque = true; 639 frame_is_opaque = true;
627 } 640 }
628 641
629 delegated_frame->render_pass_list.push_back(std::move(render_pass)); 642 delegated_frame->render_pass_list.push_back(std::move(render_pass));
630 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 643 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
(...skipping 12 matching lines...) Expand all
643 surface_id_, 656 surface_id_,
644 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), 657 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)),
645 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), 658 base::Bind(&RequireCallback, base::Unretained(surface_manager_)),
646 contents_surface_size, contents_surface_to_layer_scale, layer_size); 659 contents_surface_size, contents_surface_to_layer_scale, layer_size);
647 layer()->SetBounds(gfx::Rect(layer()->bounds().origin(), layer_size)); 660 layer()->SetBounds(gfx::Rect(layer()->bounds().origin(), layer_size));
648 layer()->SetFillsBoundsOpaquely(alpha_ == 1.0f && frame_is_opaque); 661 layer()->SetFillsBoundsOpaquely(alpha_ == 1.0f && frame_is_opaque);
649 662
650 // Reset damage. 663 // Reset damage.
651 pending_damage_.setEmpty(); 664 pending_damage_.setEmpty();
652 } 665 }
666
667 if (current_resource_.id)
reveman 2016/06/03 19:06:50 nit: please include this in the DCHECK, DCHECK(!cu
668 DCHECK(factory_owner_->release_callbacks_.count(current_resource_.id));
669
653 // Move pending frame callbacks to the end of active_frame_callbacks_ 670 // Move pending frame callbacks to the end of active_frame_callbacks_
654 active_frame_callbacks_.splice(active_frame_callbacks_.end(), 671 active_frame_callbacks_.splice(active_frame_callbacks_.end(),
655 pending_frame_callbacks_); 672 pending_frame_callbacks_);
656 } 673 }
657 674
658 void Surface::CommitSurfaceHierarchy() { 675 void Surface::CommitSurfaceHierarchy() {
659 DCHECK(needs_commit_surface_hierarchy_); 676 DCHECK(needs_commit_surface_hierarchy_);
660 needs_commit_surface_hierarchy_ = false; 677 needs_commit_surface_hierarchy_ = false;
661 678
662 if (factory_owner_) { 679 if (factory_owner_) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 void Surface::WillDraw(cc::SurfaceId id) { 881 void Surface::WillDraw(cc::SurfaceId id) {
865 while (!active_frame_callbacks_.empty()) { 882 while (!active_frame_callbacks_.empty()) {
866 active_frame_callbacks_.front().Run(base::TimeTicks::Now()); 883 active_frame_callbacks_.front().Run(base::TimeTicks::Now());
867 active_frame_callbacks_.pop_front(); 884 active_frame_callbacks_.pop_front();
868 } 885 }
869 } 886 }
870 887
871 bool Surface::use_surface_layer_ = false; 888 bool Surface::use_surface_layer_ = false;
872 889
873 } // namespace exo 890 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698