summaryrefslogtreecommitdiffstats
path: root/cc/render_pass.cc
blob: 2d499076f299209c01b8057290b81c07cc52ef75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/render_pass.h"

#include "third_party/skia/include/core/SkImageFilter.h"

namespace cc {

scoped_ptr<RenderPass> RenderPass::Create() {
  return make_scoped_ptr(new RenderPass);
}

RenderPass::RenderPass()
    : id(Id(-1, -1)),
      has_transparent_background(true),
      has_occlusion_from_outside_target_surface(false),
      filter(NULL) {
}

RenderPass::~RenderPass() {
  SkSafeUnref(filter);
}

scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const {
  DCHECK(new_id != id);

  scoped_ptr<RenderPass> copy_pass(Create());
  copy_pass->SetAll(new_id,
                    output_rect,
                    damage_rect,
                    transform_to_root_target,
                    has_transparent_background,
                    has_occlusion_from_outside_target_surface,
                    filters,
                    filter,
                    background_filters);
  return copy_pass.Pass();
}

void RenderPass::SetNew(Id id,
                        gfx::Rect output_rect,
                        gfx::RectF damage_rect,
                        const gfx::Transform& transform_to_root_target) {
  DCHECK_GT(id.layer_id, 0);
  DCHECK_GE(id.index, 0);

  this->id = id;
  this->output_rect = output_rect;
  this->damage_rect = damage_rect;
  this->transform_to_root_target = transform_to_root_target;

  DCHECK(quad_list.isEmpty());
  DCHECK(shared_quad_state_list.isEmpty());
}

void RenderPass::SetAll(Id id,
                        gfx::Rect output_rect,
                        gfx::RectF damage_rect,
                        const gfx::Transform& transform_to_root_target,
                        bool has_transparent_background,
                        bool has_occlusion_from_outside_target_surface,
                        const WebKit::WebFilterOperations& filters,
                        SkImageFilter* filter,
                        const WebKit::WebFilterOperations& background_filters) {
  DCHECK_GT(id.layer_id, 0);
  DCHECK_GE(id.index, 0);

  this->id = id;
  this->output_rect = output_rect;
  this->damage_rect = damage_rect;
  this->transform_to_root_target = transform_to_root_target;
  this->has_transparent_background = has_transparent_background;
  this->has_occlusion_from_outside_target_surface =
      has_occlusion_from_outside_target_surface;
  this->filters = filters;
  SkRefCnt_SafeAssign(this->filter, filter);
  this->background_filters = background_filters;

  DCHECK(quad_list.isEmpty());
  DCHECK(shared_quad_state_list.isEmpty());
}

}  // namespace cc