| OLD | NEW | 
|---|
| 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 "cc/blink/web_layer_impl.h" | 5 #include "cc/blink/web_layer_impl.h" | 
| 6 | 6 | 
|  | 7 #include <utility> | 
|  | 8 #include <vector> | 
|  | 9 | 
| 7 #include "base/bind.h" | 10 #include "base/bind.h" | 
| 8 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" | 
| 9 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" | 
| 10 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" | 
| 11 #include "base/trace_event/trace_event_impl.h" | 14 #include "base/trace_event/trace_event_impl.h" | 
| 12 #include "cc/animation/animation.h" | 15 #include "cc/animation/animation.h" | 
| 13 #include "cc/base/region.h" | 16 #include "cc/base/region.h" | 
| 14 #include "cc/base/switches.h" | 17 #include "cc/base/switches.h" | 
| 15 #include "cc/blink/web_animation_impl.h" | 18 #include "cc/blink/web_animation_impl.h" | 
| 16 #include "cc/blink/web_blend_mode.h" | 19 #include "cc/blink/web_blend_mode.h" | 
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 351   size_t i = 0; | 354   size_t i = 0; | 
| 352   for (cc::Region::Iterator region_rects(layer_->non_fast_scrollable_region()); | 355   for (cc::Region::Iterator region_rects(layer_->non_fast_scrollable_region()); | 
| 353        region_rects.has_rect(); | 356        region_rects.has_rect(); | 
| 354        region_rects.next()) { | 357        region_rects.next()) { | 
| 355     result[i] = region_rects.rect(); | 358     result[i] = region_rects.rect(); | 
| 356     ++i; | 359     ++i; | 
| 357   } | 360   } | 
| 358   return result; | 361   return result; | 
| 359 } | 362 } | 
| 360 | 363 | 
|  | 364 void WebLayerImpl::setFrameTimingRequests( | 
|  | 365     const WebVector<std::pair<int64_t, WebRect>>& requests) { | 
|  | 366   std::vector<cc::FrameTimingRequest> frame_timing_requests(requests.size()); | 
|  | 367   for (size_t i = 0; i < requests.size(); ++i) { | 
|  | 368     frame_timing_requests.push_back(cc::FrameTimingRequest( | 
|  | 369         requests[i].first, gfx::Rect(requests[i].second))); | 
|  | 370   } | 
|  | 371   layer_->SetFrameTimingRequests(frame_timing_requests); | 
|  | 372 } | 
|  | 373 | 
| 361 void WebLayerImpl::setTouchEventHandlerRegion(const WebVector<WebRect>& rects) { | 374 void WebLayerImpl::setTouchEventHandlerRegion(const WebVector<WebRect>& rects) { | 
| 362   cc::Region region; | 375   cc::Region region; | 
| 363   for (size_t i = 0; i < rects.size(); ++i) | 376   for (size_t i = 0; i < rects.size(); ++i) | 
| 364     region.Union(rects[i]); | 377     region.Union(rects[i]); | 
| 365   layer_->SetTouchEventHandlerRegion(region); | 378   layer_->SetTouchEventHandlerRegion(region); | 
| 366 } | 379 } | 
| 367 | 380 | 
| 368 WebVector<WebRect> WebLayerImpl::touchEventHandlerRegion() const { | 381 WebVector<WebRect> WebLayerImpl::touchEventHandlerRegion() const { | 
| 369   size_t num_rects = 0; | 382   size_t num_rects = 0; | 
| 370   for (cc::Region::Iterator region_rects(layer_->touch_event_handler_region()); | 383   for (cc::Region::Iterator region_rects(layer_->touch_event_handler_region()); | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 451 } | 464 } | 
| 452 | 465 | 
| 453 bool WebLayerImpl::isOrphan() const { | 466 bool WebLayerImpl::isOrphan() const { | 
| 454   return !layer_->layer_tree_host(); | 467   return !layer_->layer_tree_host(); | 
| 455 } | 468 } | 
| 456 | 469 | 
| 457 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 470 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 
| 458   web_layer_client_ = client; | 471   web_layer_client_ = client; | 
| 459 } | 472 } | 
| 460 | 473 | 
| 461 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { | 474 class TracedDebugInfo : public base::trace_event::ConvertableToTraceFormat { | 
| 462  public: | 475  public: | 
| 463   // This object takes ownership of the debug_info object. | 476   // This object takes ownership of the debug_info object. | 
| 464   explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) | 477   explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) | 
| 465       : debug_info_(debug_info) {} | 478       : debug_info_(debug_info) {} | 
| 466   void AppendAsTraceFormat(std::string* out) const override { | 479   void AppendAsTraceFormat(std::string* out) const override { | 
| 467     DCHECK(thread_checker_.CalledOnValidThread()); | 480     DCHECK(thread_checker_.CalledOnValidThread()); | 
| 468     blink::WebString web_string; | 481     blink::WebString web_string; | 
| 469     debug_info_->appendAsTraceFormat(&web_string); | 482     debug_info_->appendAsTraceFormat(&web_string); | 
| 470     out->append(web_string.utf8()); | 483     out->append(web_string.utf8()); | 
| 471   } | 484   } | 
| 472 | 485 | 
| 473  private: | 486  private: | 
| 474   ~TracedDebugInfo() override {} | 487   ~TracedDebugInfo() override {} | 
| 475   scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; | 488   scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; | 
| 476   base::ThreadChecker thread_checker_; | 489   base::ThreadChecker thread_checker_; | 
| 477 }; | 490 }; | 
| 478 | 491 | 
| 479 scoped_refptr<base::debug::ConvertableToTraceFormat> | 492 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 
| 480 WebLayerImpl::TakeDebugInfo() { | 493 WebLayerImpl::TakeDebugInfo() { | 
| 481   if (!web_layer_client_) | 494   if (!web_layer_client_) | 
| 482     return nullptr; | 495     return nullptr; | 
| 483   blink::WebGraphicsLayerDebugInfo* debug_info = | 496   blink::WebGraphicsLayerDebugInfo* debug_info = | 
| 484       web_layer_client_->takeDebugInfoFor(this); | 497       web_layer_client_->takeDebugInfoFor(this); | 
| 485 | 498 | 
| 486   if (debug_info) | 499   if (debug_info) | 
| 487     return new TracedDebugInfo(debug_info); | 500     return new TracedDebugInfo(debug_info); | 
| 488   else | 501   else | 
| 489     return nullptr; | 502     return nullptr; | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 501   if (parent) | 514   if (parent) | 
| 502     clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 515     clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 
| 503   layer_->SetClipParent(clip_parent); | 516   layer_->SetClipParent(clip_parent); | 
| 504 } | 517 } | 
| 505 | 518 | 
| 506 Layer* WebLayerImpl::layer() const { | 519 Layer* WebLayerImpl::layer() const { | 
| 507   return layer_.get(); | 520   return layer_.get(); | 
| 508 } | 521 } | 
| 509 | 522 | 
| 510 }  // namespace cc_blink | 523 }  // namespace cc_blink | 
| OLD | NEW | 
|---|