OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_COMPOSITOR_LAYER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_H_ |
6 #define UI_COMPOSITOR_LAYER_H_ | 6 #define UI_COMPOSITOR_LAYER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 static void ConvertPointToLayer(const Layer* source, | 234 static void ConvertPointToLayer(const Layer* source, |
235 const Layer* target, | 235 const Layer* target, |
236 gfx::Point* point); | 236 gfx::Point* point); |
237 | 237 |
238 // Converts a transform to be relative to the given |ancestor|. Returns | 238 // Converts a transform to be relative to the given |ancestor|. Returns |
239 // whether success (that is, whether the given ancestor was really an | 239 // whether success (that is, whether the given ancestor was really an |
240 // ancestor of this layer). | 240 // ancestor of this layer). |
241 bool GetTargetTransformRelativeTo(const Layer* ancestor, | 241 bool GetTargetTransformRelativeTo(const Layer* ancestor, |
242 gfx::Transform* transform) const; | 242 gfx::Transform* transform) const; |
243 | 243 |
244 // Converts a ui::Layer's transform to the transform on the corresponding | |
245 // cc::Layer. | |
246 static gfx::Transform ConvertTransformToCCTransform( | |
247 const gfx::Transform& transform, | |
248 float device_scale_factor); | |
249 | |
250 // See description in View for details | 244 // See description in View for details |
251 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); | 245 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); |
252 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } | 246 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } |
253 | 247 |
254 // Set to true if this layer always paints completely within its bounds. If so | 248 // Set to true if this layer always paints completely within its bounds. If so |
255 // we can omit an unnecessary clear, even if the layer is transparent. | 249 // we can omit an unnecessary clear, even if the layer is transparent. |
256 void SetFillsBoundsCompletely(bool fills_bounds_completely); | 250 void SetFillsBoundsCompletely(bool fills_bounds_completely); |
257 | 251 |
258 const std::string& name() const { return name_; } | 252 const std::string& name() const { return name_; } |
259 void set_name(const std::string& name) { name_ = name; } | 253 void set_name(const std::string& name) { name_ = name; } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void SendDamagedRects(); | 286 void SendDamagedRects(); |
293 | 287 |
294 const SkRegion& damaged_region() const { return damaged_region_; } | 288 const SkRegion& damaged_region() const { return damaged_region_; } |
295 | 289 |
296 // Suppresses painting the content by disconnecting |delegate_|. | 290 // Suppresses painting the content by disconnecting |delegate_|. |
297 void SuppressPaint(); | 291 void SuppressPaint(); |
298 | 292 |
299 // Notifies the layer that the device scale factor has changed. | 293 // Notifies the layer that the device scale factor has changed. |
300 void OnDeviceScaleFactorChanged(float device_scale_factor); | 294 void OnDeviceScaleFactorChanged(float device_scale_factor); |
301 | 295 |
302 // Sets whether the layer should scale its content. If true, the canvas will | |
303 // be scaled in software rendering mode before it is passed to | |
304 // |LayerDelegate::OnPaintLayer|. | |
305 // Set to false if the delegate handles scaling. | |
306 // NOTE: if this is called during |LayerDelegate::OnPaint|, the new value will | |
307 // not apply to the canvas passed to the pending draw. | |
308 void set_scale_content(bool scale_content) { scale_content_ = scale_content; } | |
309 | |
310 // Returns true if the layer scales its content. | |
311 bool scale_content() const { return scale_content_; } | |
312 | |
313 // Requets a copy of the layer's output as a texture or bitmap. | 296 // Requets a copy of the layer's output as a texture or bitmap. |
314 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); | 297 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); |
315 | 298 |
316 // ContentLayerClient | 299 // ContentLayerClient |
317 virtual void PaintContents( | 300 virtual void PaintContents( |
318 SkCanvas* canvas, | 301 SkCanvas* canvas, |
319 const gfx::Rect& clip, | 302 const gfx::Rect& clip, |
320 gfx::RectF* opaque, | 303 gfx::RectF* opaque, |
321 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE; | 304 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE; |
322 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} | 305 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 virtual SkColor GetColorForAnimation() const OVERRIDE; | 364 virtual SkColor GetColorForAnimation() const OVERRIDE; |
382 virtual float GetDeviceScaleFactor() const OVERRIDE; | 365 virtual float GetDeviceScaleFactor() const OVERRIDE; |
383 virtual void AddThreadedAnimation( | 366 virtual void AddThreadedAnimation( |
384 scoped_ptr<cc::Animation> animation) OVERRIDE; | 367 scoped_ptr<cc::Animation> animation) OVERRIDE; |
385 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; | 368 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; |
386 | 369 |
387 // Creates a corresponding composited layer for |type_|. | 370 // Creates a corresponding composited layer for |type_|. |
388 void CreateWebLayer(); | 371 void CreateWebLayer(); |
389 | 372 |
390 // Recomputes and sets to |cc_layer_|. | 373 // Recomputes and sets to |cc_layer_|. |
391 void RecomputeCCTransformFromTransform(const gfx::Transform& transform); | |
392 void RecomputeDrawsContentAndUVRect(); | 374 void RecomputeDrawsContentAndUVRect(); |
393 void RecomputePosition(); | 375 void RecomputePosition(); |
394 | 376 |
395 // Set all filters which got applied to the layer. | 377 // Set all filters which got applied to the layer. |
396 void SetLayerFilters(); | 378 void SetLayerFilters(); |
397 | 379 |
398 // Set all filters which got applied to the layer background. | 380 // Set all filters which got applied to the layer background. |
399 void SetLayerBackgroundFilters(); | 381 void SetLayerBackgroundFilters(); |
400 | 382 |
401 // Cleanup |cc_layer_| and replaces it with |new_layer|. | 383 // Cleanup |cc_layer_| and replaces it with |new_layer|. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 cc::ScopedPtrVector<cc::Animation> pending_threaded_animations_; | 451 cc::ScopedPtrVector<cc::Animation> pending_threaded_animations_; |
470 | 452 |
471 // Ownership of the layer is held through one of the strongly typed layer | 453 // Ownership of the layer is held through one of the strongly typed layer |
472 // pointers, depending on which sort of layer this is. | 454 // pointers, depending on which sort of layer this is. |
473 scoped_refptr<cc::Layer> content_layer_; | 455 scoped_refptr<cc::Layer> content_layer_; |
474 scoped_refptr<cc::TextureLayer> texture_layer_; | 456 scoped_refptr<cc::TextureLayer> texture_layer_; |
475 scoped_refptr<cc::SolidColorLayer> solid_color_layer_; | 457 scoped_refptr<cc::SolidColorLayer> solid_color_layer_; |
476 scoped_refptr<cc::DelegatedRendererLayer> delegated_renderer_layer_; | 458 scoped_refptr<cc::DelegatedRendererLayer> delegated_renderer_layer_; |
477 cc::Layer* cc_layer_; | 459 cc::Layer* cc_layer_; |
478 | 460 |
479 // If true, the layer scales the canvas and the texture with the device scale | |
480 // factor as apporpriate. When true, the texture size is in DIP. | |
481 bool scale_content_; | |
482 | |
483 // A cached copy of |Compositor::device_scale_factor()|. | 461 // A cached copy of |Compositor::device_scale_factor()|. |
484 float device_scale_factor_; | 462 float device_scale_factor_; |
485 | 463 |
486 // The mailbox used by texture_layer_. | 464 // The mailbox used by texture_layer_. |
487 cc::TextureMailbox mailbox_; | 465 cc::TextureMailbox mailbox_; |
488 | 466 |
489 // The callback to release the mailbox. This is only set after | 467 // The callback to release the mailbox. This is only set after |
490 // SetTextureMailbox is called, before we give it to the TextureLayer. | 468 // SetTextureMailbox is called, before we give it to the TextureLayer. |
491 scoped_ptr<cc::SingleReleaseCallback> mailbox_release_callback_; | 469 scoped_ptr<cc::SingleReleaseCallback> mailbox_release_callback_; |
492 | 470 |
493 // The size of the frame or texture in DIP, set when SetShowDelegatedContent | 471 // The size of the frame or texture in DIP, set when SetShowDelegatedContent |
494 // or SetTextureMailbox was called. | 472 // or SetTextureMailbox was called. |
495 gfx::Size frame_size_in_dip_; | 473 gfx::Size frame_size_in_dip_; |
496 | 474 |
497 DISALLOW_COPY_AND_ASSIGN(Layer); | 475 DISALLOW_COPY_AND_ASSIGN(Layer); |
498 }; | 476 }; |
499 | 477 |
500 } // namespace ui | 478 } // namespace ui |
501 | 479 |
502 #endif // UI_COMPOSITOR_LAYER_H_ | 480 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |