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

Side by Side Diff: services/gfx/compositor/graph/node_def.cc

Issue 1781993002: Mozart: Compute hits using 4x4 matrix. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-10
Patch Set: Created 4 years, 9 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 | « services/gfx/compositor/graph/node_def.h ('k') | services/gfx/compositor/graph/scene_content.h » ('j') | 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 "services/gfx/compositor/graph/node_def.h" 5 #include "services/gfx/compositor/graph/node_def.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/services/gfx/composition/cpp/formatting.h" 10 #include "mojo/services/gfx/composition/cpp/formatting.h"
11 #include "mojo/skia/type_converters.h" 11 #include "mojo/skia/type_converters.h"
12 #include "services/gfx/compositor/graph/scene_content.h" 12 #include "services/gfx/compositor/graph/scene_content.h"
13 #include "services/gfx/compositor/graph/scene_def.h" 13 #include "services/gfx/compositor/graph/scene_def.h"
14 #include "services/gfx/compositor/graph/snapshot.h" 14 #include "services/gfx/compositor/graph/snapshot.h"
15 #include "services/gfx/compositor/graph/transform_pair.h"
15 #include "services/gfx/compositor/render/render_image.h" 16 #include "services/gfx/compositor/render/render_image.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 17 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/core/SkColor.h" 18 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkMatrix.h" 19 #include "third_party/skia/include/core/SkMatrix.h"
19 #include "third_party/skia/include/core/SkPaint.h" 20 #include "third_party/skia/include/core/SkPaint.h"
20 #include "third_party/skia/include/core/SkPoint.h" 21 #include "third_party/skia/include/core/SkPoint.h"
21 #include "third_party/skia/include/core/SkRect.h" 22 #include "third_party/skia/include/core/SkRect.h"
23 #include "third_party/skia/include/utils/SkMatrix44.h"
22 24
23 namespace compositor { 25 namespace compositor {
24 namespace { 26 namespace {
25 SkColor MakeSkColor(const mojo::gfx::composition::Color& color) { 27 SkColor MakeSkColor(const mojo::gfx::composition::Color& color) {
26 return SkColorSetARGBInline(color.alpha, color.red, color.green, color.blue); 28 return SkColorSetARGBInline(color.alpha, color.red, color.green, color.blue);
27 } 29 }
28 30
29 void SetPaintForBlend(SkPaint* paint, mojo::gfx::composition::Blend* blend) { 31 void SetPaintForBlend(SkPaint* paint, mojo::gfx::composition::Blend* blend) {
30 DCHECK(paint); 32 DCHECK(paint);
31 if (blend) 33 if (blend)
32 paint->setAlpha(blend->alpha); 34 paint->setAlpha(blend->alpha);
33 } 35 }
34 36
35 bool Contains(const SkRect& bounds, const SkPoint& point) { 37 bool Contains(const SkRect& bounds, const SkPoint& point) {
36 return point.x() >= bounds.left() && point.x() < bounds.right() && 38 return point.x() >= bounds.left() && point.x() < bounds.right() &&
37 point.y() >= bounds.top() && point.y() < bounds.bottom(); 39 point.y() >= bounds.top() && point.y() < bounds.bottom();
38 } 40 }
39 } // namespace 41 } // namespace
40 42
41 NodeDef::NodeDef(uint32_t node_id, 43 NodeDef::NodeDef(uint32_t node_id,
42 mojo::TransformPtr content_transform, 44 std::unique_ptr<TransformPair> content_transform,
43 mojo::RectFPtr content_clip, 45 mojo::RectFPtr content_clip,
44 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, 46 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior,
45 Combinator combinator, 47 Combinator combinator,
46 const std::vector<uint32_t>& child_node_ids) 48 const std::vector<uint32_t>& child_node_ids)
47 : node_id_(node_id), 49 : node_id_(node_id),
48 content_transform_(content_transform.Pass()), 50 content_transform_(std::move(content_transform)),
49 content_clip_(content_clip.Pass()), 51 content_clip_(content_clip.Pass()),
50 hit_test_behavior_(hit_test_behavior.Pass()), 52 hit_test_behavior_(hit_test_behavior.Pass()),
51 combinator_(combinator), 53 combinator_(combinator),
52 child_node_ids_(child_node_ids) {} 54 child_node_ids_(child_node_ids) {}
53 55
54 NodeDef::~NodeDef() {} 56 NodeDef::~NodeDef() {}
55 57
56 std::string NodeDef::FormattedLabel(const SceneContent* content) const { 58 std::string NodeDef::FormattedLabel(const SceneContent* content) const {
57 return content->FormattedLabelForNode(node_id_); 59 return content->FormattedLabelForNode(node_id_);
58 } 60 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const Snapshot* snapshot, 200 const Snapshot* snapshot,
199 SkCanvas* canvas) const { 201 SkCanvas* canvas) const {
200 DCHECK(content); 202 DCHECK(content);
201 DCHECK(snapshot); 203 DCHECK(snapshot);
202 DCHECK(canvas); 204 DCHECK(canvas);
203 205
204 const bool must_save = content_transform_ || content_clip_; 206 const bool must_save = content_transform_ || content_clip_;
205 if (must_save) { 207 if (must_save) {
206 canvas->save(); 208 canvas->save();
207 if (content_transform_) 209 if (content_transform_)
208 canvas->concat(content_transform_.To<SkMatrix>()); 210 canvas->concat(content_transform_->forward());
209 if (content_clip_) 211 if (content_clip_)
210 canvas->clipRect(content_clip_->To<SkRect>()); 212 canvas->clipRect(content_clip_->To<SkRect>());
211 } 213 }
212 214
213 RecordPictureInner(content, snapshot, canvas); 215 RecordPictureInner(content, snapshot, canvas);
214 216
215 if (must_save) 217 if (must_save)
216 canvas->restore(); 218 canvas->restore();
217 } 219 }
218 220
219 void NodeDef::RecordPictureInner(const SceneContent* content, 221 void NodeDef::RecordPictureInner(const SceneContent* content,
220 const Snapshot* snapshot, 222 const Snapshot* snapshot,
221 SkCanvas* canvas) const { 223 SkCanvas* canvas) const {
222 DCHECK(content); 224 DCHECK(content);
223 DCHECK(snapshot); 225 DCHECK(snapshot);
224 DCHECK(canvas); 226 DCHECK(canvas);
225 227
226 TraverseSnapshottedChildren( 228 TraverseSnapshottedChildren(
227 content, snapshot, 229 content, snapshot,
228 [this, content, snapshot, canvas](const NodeDef* child_node) -> bool { 230 [this, content, snapshot, canvas](const NodeDef* child_node) -> bool {
229 child_node->RecordPicture(content, snapshot, canvas); 231 child_node->RecordPicture(content, snapshot, canvas);
230 return true; 232 return true;
231 }); 233 });
232 } 234 }
233 235
234 bool NodeDef::HitTest(const SceneContent* content, 236 bool NodeDef::HitTest(const SceneContent* content,
235 const Snapshot* snapshot, 237 const Snapshot* snapshot,
236 const SkPoint& parent_point, 238 const SkPoint& parent_point,
237 const SkMatrix& global_to_parent_transform, 239 const SkMatrix44& global_to_parent_transform,
238 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const { 240 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const {
239 DCHECK(content); 241 DCHECK(content);
240 DCHECK(snapshot); 242 DCHECK(snapshot);
241 DCHECK(hits); 243 DCHECK(hits);
242 244
243 // TODO(jeffbrown): These calculations should probably be happening using 245 // TODO(jeffbrown): These calculations should probably be happening using
244 // a 4x4 matrix instead. 246 // a 4x4 matrix instead.
245 SkPoint local_point = parent_point; 247 SkPoint local_point(parent_point);
246 SkMatrix global_to_local_transform = global_to_parent_transform; 248 SkMatrix global_to_local_transform(global_to_parent_transform);
247 if (content_transform_) { 249 if (content_transform_) {
248 // TODO(jeffbrown): Cache the inverse transform. 250 // TODO(jeffbrown): Defer matrix multiplications using a matrix stack.
249 // Defer matrix multiplications using a matrix stack. 251 local_point = content_transform_->InverseMapPoint(parent_point);
250 SkMatrix inverse_transform; 252 global_to_local_transform.preConcat(content_transform_->GetInverse());
251 if (!content_transform_.To<SkMatrix>().invert(&inverse_transform)) {
252 // Matrix is singular!
253 // Return [0,0,0][0,0,0][0,0,1] (all zeroes except last component).
254 // This causes all points to be mapped to (0,0) when transformed.
255 inverse_transform.setScale(0.f, 0.f);
256 }
257 inverse_transform.mapXY(parent_point.x(), parent_point.y(), &local_point);
258 global_to_local_transform.preConcat(inverse_transform);
259 } 253 }
260 254
261 if (content_clip_ && !Contains(content_clip_->To<SkRect>(), local_point)) 255 if (content_clip_ && !Contains(content_clip_->To<SkRect>(), local_point))
262 return false; 256 return false;
263 257
264 bool opaque_children = false; 258 bool opaque_children = false;
265 if (!hit_test_behavior_ || !hit_test_behavior_->prune) { 259 if (!hit_test_behavior_ || !hit_test_behavior_->prune) {
266 opaque_children = HitTestInner(content, snapshot, local_point, 260 opaque_children = HitTestInner(content, snapshot, local_point,
267 global_to_local_transform, hits); 261 global_to_local_transform, hits);
268 } 262 }
269 263
270 return HitTestSelf(content, snapshot, local_point, global_to_local_transform, 264 return HitTestSelf(content, snapshot, local_point, global_to_local_transform,
271 hits) || 265 hits) ||
272 opaque_children; 266 opaque_children;
273 } 267 }
274 268
275 bool NodeDef::HitTestInner( 269 bool NodeDef::HitTestInner(
276 const SceneContent* content, 270 const SceneContent* content,
277 const Snapshot* snapshot, 271 const Snapshot* snapshot,
278 const SkPoint& local_point, 272 const SkPoint& local_point,
279 const SkMatrix& global_to_local_transform, 273 const SkMatrix44& global_to_local_transform,
280 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const { 274 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const {
281 DCHECK(content); 275 DCHECK(content);
282 DCHECK(snapshot); 276 DCHECK(snapshot);
283 DCHECK(hits); 277 DCHECK(hits);
284 278
285 // TODO(jeffbrown): Implement a more efficient way to traverse children in 279 // TODO(jeffbrown): Implement a more efficient way to traverse children in
286 // reverse order. 280 // reverse order.
287 std::vector<const NodeDef*> children; 281 std::vector<const NodeDef*> children;
288 TraverseSnapshottedChildren( 282 TraverseSnapshottedChildren(
289 content, snapshot, [this, &children](const NodeDef* child_node) -> bool { 283 content, snapshot, [this, &children](const NodeDef* child_node) -> bool {
290 children.push_back(child_node); 284 children.push_back(child_node);
291 return true; 285 return true;
292 }); 286 });
293 287
294 for (auto it = children.crbegin(); it != children.crend(); ++it) { 288 for (auto it = children.crbegin(); it != children.crend(); ++it) {
295 if ((*it)->HitTest(content, snapshot, local_point, 289 if ((*it)->HitTest(content, snapshot, local_point,
296 global_to_local_transform, hits)) 290 global_to_local_transform, hits))
297 return true; // opaque child covering siblings 291 return true; // opaque child covering siblings
298 } 292 }
299 return false; 293 return false;
300 } 294 }
301 295
302 bool NodeDef::HitTestSelf( 296 bool NodeDef::HitTestSelf(
303 const SceneContent* content, 297 const SceneContent* content,
304 const Snapshot* snapshot, 298 const Snapshot* snapshot,
305 const SkPoint& local_point, 299 const SkPoint& local_point,
306 const SkMatrix& global_to_local_transform, 300 const SkMatrix44& global_to_local_transform,
307 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const { 301 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const {
308 DCHECK(content); 302 DCHECK(content);
309 DCHECK(snapshot); 303 DCHECK(snapshot);
310 DCHECK(hits); 304 DCHECK(hits);
311 305
312 if (!hit_test_behavior_ || 306 if (!hit_test_behavior_ ||
313 hit_test_behavior_->visibility == 307 hit_test_behavior_->visibility ==
314 mojo::gfx::composition::HitTestBehavior::Visibility::INVISIBLE) 308 mojo::gfx::composition::HitTestBehavior::Visibility::INVISIBLE)
315 return false; 309 return false;
316 310
317 if (hit_test_behavior_->hit_rect && 311 if (hit_test_behavior_->hit_rect &&
318 !Contains(hit_test_behavior_->hit_rect->To<SkRect>(), local_point)) 312 !Contains(hit_test_behavior_->hit_rect->To<SkRect>(), local_point))
319 return false; 313 return false;
320 314
321 auto hit = mojo::gfx::composition::Hit::New(); 315 auto hit = mojo::gfx::composition::Hit::New();
322 hit->set_node(mojo::gfx::composition::NodeHit::New()); 316 hit->set_node(mojo::gfx::composition::NodeHit::New());
323 hit->get_node()->node_id = node_id_; 317 hit->get_node()->node_id = node_id_;
324 hit->get_node()->transform = 318 hit->get_node()->transform =
325 mojo::ConvertTo<mojo::TransformPtr>(global_to_local_transform); 319 mojo::ConvertTo<mojo::TransformPtr>(global_to_local_transform);
326 hits->push_back(hit.Pass()); 320 hits->push_back(hit.Pass());
327 return hit_test_behavior_->visibility == 321 return hit_test_behavior_->visibility ==
328 mojo::gfx::composition::HitTestBehavior::Visibility::OPAQUE; 322 mojo::gfx::composition::HitTestBehavior::Visibility::OPAQUE;
329 } 323 }
330 324
331 RectNodeDef::RectNodeDef( 325 RectNodeDef::RectNodeDef(
332 uint32_t node_id, 326 uint32_t node_id,
333 mojo::TransformPtr content_transform, 327 std::unique_ptr<TransformPair> content_transform,
334 mojo::RectFPtr content_clip, 328 mojo::RectFPtr content_clip,
335 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, 329 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior,
336 Combinator combinator, 330 Combinator combinator,
337 const std::vector<uint32_t>& child_node_ids, 331 const std::vector<uint32_t>& child_node_ids,
338 const mojo::RectF& content_rect, 332 const mojo::RectF& content_rect,
339 const mojo::gfx::composition::Color& color) 333 const mojo::gfx::composition::Color& color)
340 : NodeDef(node_id, 334 : NodeDef(node_id,
341 content_transform.Pass(), 335 std::move(content_transform),
342 content_clip.Pass(), 336 content_clip.Pass(),
343 hit_test_behavior.Pass(), 337 hit_test_behavior.Pass(),
344 combinator, 338 combinator,
345 child_node_ids), 339 child_node_ids),
346 content_rect_(content_rect), 340 content_rect_(content_rect),
347 color_(color) {} 341 color_(color) {}
348 342
349 RectNodeDef::~RectNodeDef() {} 343 RectNodeDef::~RectNodeDef() {}
350 344
351 void RectNodeDef::RecordPictureInner(const SceneContent* content, 345 void RectNodeDef::RecordPictureInner(const SceneContent* content,
352 const Snapshot* snapshot, 346 const Snapshot* snapshot,
353 SkCanvas* canvas) const { 347 SkCanvas* canvas) const {
354 DCHECK(content); 348 DCHECK(content);
355 DCHECK(snapshot); 349 DCHECK(snapshot);
356 DCHECK(canvas); 350 DCHECK(canvas);
357 351
358 SkPaint paint; 352 SkPaint paint;
359 paint.setColor(MakeSkColor(color_)); 353 paint.setColor(MakeSkColor(color_));
360 canvas->drawRect(content_rect_.To<SkRect>(), paint); 354 canvas->drawRect(content_rect_.To<SkRect>(), paint);
361 355
362 NodeDef::RecordPictureInner(content, snapshot, canvas); 356 NodeDef::RecordPictureInner(content, snapshot, canvas);
363 } 357 }
364 358
365 ImageNodeDef::ImageNodeDef( 359 ImageNodeDef::ImageNodeDef(
366 uint32_t node_id, 360 uint32_t node_id,
367 mojo::TransformPtr content_transform, 361 std::unique_ptr<TransformPair> content_transform,
368 mojo::RectFPtr content_clip, 362 mojo::RectFPtr content_clip,
369 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, 363 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior,
370 Combinator combinator, 364 Combinator combinator,
371 const std::vector<uint32_t>& child_node_ids, 365 const std::vector<uint32_t>& child_node_ids,
372 const mojo::RectF& content_rect, 366 const mojo::RectF& content_rect,
373 mojo::RectFPtr image_rect, 367 mojo::RectFPtr image_rect,
374 uint32 image_resource_id, 368 uint32 image_resource_id,
375 mojo::gfx::composition::BlendPtr blend) 369 mojo::gfx::composition::BlendPtr blend)
376 : NodeDef(node_id, 370 : NodeDef(node_id,
377 content_transform.Pass(), 371 std::move(content_transform),
378 content_clip.Pass(), 372 content_clip.Pass(),
379 hit_test_behavior.Pass(), 373 hit_test_behavior.Pass(),
380 combinator, 374 combinator,
381 child_node_ids), 375 child_node_ids),
382 content_rect_(content_rect), 376 content_rect_(content_rect),
383 image_rect_(image_rect.Pass()), 377 image_rect_(image_rect.Pass()),
384 image_resource_id_(image_resource_id), 378 image_resource_id_(image_resource_id),
385 blend_(blend.Pass()) {} 379 blend_(blend.Pass()) {}
386 380
387 ImageNodeDef::~ImageNodeDef() {} 381 ImageNodeDef::~ImageNodeDef() {}
(...skipping 25 matching lines...) Expand all
413 ? image_rect_->To<SkRect>() 407 ? image_rect_->To<SkRect>()
414 : SkRect::MakeWH(image_resource->image()->width(), 408 : SkRect::MakeWH(image_resource->image()->width(),
415 image_resource->image()->height()), 409 image_resource->image()->height()),
416 content_rect_.To<SkRect>(), &paint); 410 content_rect_.To<SkRect>(), &paint);
417 411
418 NodeDef::RecordPictureInner(content, snapshot, canvas); 412 NodeDef::RecordPictureInner(content, snapshot, canvas);
419 } 413 }
420 414
421 SceneNodeDef::SceneNodeDef( 415 SceneNodeDef::SceneNodeDef(
422 uint32_t node_id, 416 uint32_t node_id,
423 mojo::TransformPtr content_transform, 417 std::unique_ptr<TransformPair> content_transform,
424 mojo::RectFPtr content_clip, 418 mojo::RectFPtr content_clip,
425 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, 419 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior,
426 Combinator combinator, 420 Combinator combinator,
427 const std::vector<uint32_t>& child_node_ids, 421 const std::vector<uint32_t>& child_node_ids,
428 uint32_t scene_resource_id, 422 uint32_t scene_resource_id,
429 uint32_t scene_version) 423 uint32_t scene_version)
430 : NodeDef(node_id, 424 : NodeDef(node_id,
431 content_transform.Pass(), 425 std::move(content_transform),
432 content_clip.Pass(), 426 content_clip.Pass(),
433 hit_test_behavior.Pass(), 427 hit_test_behavior.Pass(),
434 combinator, 428 combinator,
435 child_node_ids), 429 child_node_ids),
436 scene_resource_id_(scene_resource_id), 430 scene_resource_id_(scene_resource_id),
437 scene_version_(scene_version) {} 431 scene_version_(scene_version) {}
438 432
439 SceneNodeDef::~SceneNodeDef() {} 433 SceneNodeDef::~SceneNodeDef() {}
440 434
441 bool SceneNodeDef::RecordContent(SceneContentBuilder* builder) const { 435 bool SceneNodeDef::RecordContent(SceneContentBuilder* builder) const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 DCHECK(resolved_content); 479 DCHECK(resolved_content);
486 resolved_content->RecordPicture(snapshot, canvas); 480 resolved_content->RecordPicture(snapshot, canvas);
487 481
488 NodeDef::RecordPictureInner(content, snapshot, canvas); 482 NodeDef::RecordPictureInner(content, snapshot, canvas);
489 } 483 }
490 484
491 bool SceneNodeDef::HitTestInner( 485 bool SceneNodeDef::HitTestInner(
492 const SceneContent* content, 486 const SceneContent* content,
493 const Snapshot* snapshot, 487 const Snapshot* snapshot,
494 const SkPoint& local_point, 488 const SkPoint& local_point,
495 const SkMatrix& global_to_local_transform, 489 const SkMatrix44& global_to_local_transform,
496 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const { 490 mojo::Array<mojo::gfx::composition::HitPtr>* hits) const {
497 DCHECK(content); 491 DCHECK(content);
498 DCHECK(snapshot); 492 DCHECK(snapshot);
499 DCHECK(hits); 493 DCHECK(hits);
500 494
501 if (NodeDef::HitTestInner(content, snapshot, local_point, 495 if (NodeDef::HitTestInner(content, snapshot, local_point,
502 global_to_local_transform, hits)) 496 global_to_local_transform, hits))
503 return true; // opaque child covering referenced scene 497 return true; // opaque child covering referenced scene
504 498
505 const SceneContent* resolved_content = 499 const SceneContent* resolved_content =
506 snapshot->GetResolvedSceneContent(this); 500 snapshot->GetResolvedSceneContent(this);
507 DCHECK(resolved_content); 501 DCHECK(resolved_content);
508 502
509 mojo::gfx::composition::SceneHitPtr scene_hit; 503 mojo::gfx::composition::SceneHitPtr scene_hit;
510 bool opaque = resolved_content->HitTest( 504 bool opaque = resolved_content->HitTest(
511 snapshot, local_point, global_to_local_transform, &scene_hit); 505 snapshot, local_point, global_to_local_transform, &scene_hit);
512 if (scene_hit) { 506 if (scene_hit) {
513 auto hit = mojo::gfx::composition::Hit::New(); 507 auto hit = mojo::gfx::composition::Hit::New();
514 hit->set_scene(scene_hit.Pass()); 508 hit->set_scene(scene_hit.Pass());
515 hits->push_back(hit.Pass()); 509 hits->push_back(hit.Pass());
516 } 510 }
517 return opaque; 511 return opaque;
518 } 512 }
519 513
520 LayerNodeDef::LayerNodeDef( 514 LayerNodeDef::LayerNodeDef(
521 uint32_t node_id, 515 uint32_t node_id,
522 mojo::TransformPtr content_transform, 516 std::unique_ptr<TransformPair> content_transform,
523 mojo::RectFPtr content_clip, 517 mojo::RectFPtr content_clip,
524 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior, 518 mojo::gfx::composition::HitTestBehaviorPtr hit_test_behavior,
525 Combinator combinator, 519 Combinator combinator,
526 const std::vector<uint32_t>& child_node_ids, 520 const std::vector<uint32_t>& child_node_ids,
527 const mojo::RectF& layer_rect, 521 const mojo::RectF& layer_rect,
528 mojo::gfx::composition::BlendPtr blend) 522 mojo::gfx::composition::BlendPtr blend)
529 : NodeDef(node_id, 523 : NodeDef(node_id,
530 content_transform.Pass(), 524 std::move(content_transform),
531 content_clip.Pass(), 525 content_clip.Pass(),
532 hit_test_behavior.Pass(), 526 hit_test_behavior.Pass(),
533 combinator, 527 combinator,
534 child_node_ids), 528 child_node_ids),
535 layer_rect_(layer_rect), 529 layer_rect_(layer_rect),
536 blend_(blend.Pass()) {} 530 blend_(blend.Pass()) {}
537 531
538 LayerNodeDef::~LayerNodeDef() {} 532 LayerNodeDef::~LayerNodeDef() {}
539 533
540 void LayerNodeDef::RecordPictureInner(const SceneContent* content, 534 void LayerNodeDef::RecordPictureInner(const SceneContent* content,
541 const Snapshot* snapshot, 535 const Snapshot* snapshot,
542 SkCanvas* canvas) const { 536 SkCanvas* canvas) const {
543 DCHECK(content); 537 DCHECK(content);
544 DCHECK(snapshot); 538 DCHECK(snapshot);
545 DCHECK(canvas); 539 DCHECK(canvas);
546 540
547 SkPaint paint; 541 SkPaint paint;
548 SetPaintForBlend(&paint, blend_.get()); 542 SetPaintForBlend(&paint, blend_.get());
549 543
550 canvas->saveLayer(layer_rect_.To<SkRect>(), &paint); 544 canvas->saveLayer(layer_rect_.To<SkRect>(), &paint);
551 NodeDef::RecordPictureInner(content, snapshot, canvas); 545 NodeDef::RecordPictureInner(content, snapshot, canvas);
552 canvas->restore(); 546 canvas->restore();
553 } 547 }
554 548
555 } // namespace compositor 549 } // namespace compositor
OLDNEW
« no previous file with comments | « services/gfx/compositor/graph/node_def.h ('k') | services/gfx/compositor/graph/scene_content.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698