blob: fe3bcdcc13b38bdb7daab51da5f357363e74495c (
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Copyright 2012 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 "config.h"
#include "CCDrawQuad.h"
#include "CCCheckerboardDrawQuad.h"
#include "CCDebugBorderDrawQuad.h"
#include "CCIOSurfaceDrawQuad.h"
#include "CCRenderPassDrawQuad.h"
#include "CCTileDrawQuad.h"
#include "CCYUVVideoDrawQuad.h"
#include "base/logging.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/stream_video_draw_quad.h"
#include "cc/texture_draw_quad.h"
namespace cc {
CCDrawQuad::CCDrawQuad(const CCSharedQuadState* sharedQuadState, Material material, const gfx::Rect& quadRect)
: m_sharedQuadState(sharedQuadState)
, m_sharedQuadStateId(sharedQuadState->id)
, m_material(material)
, m_quadRect(quadRect)
, m_quadVisibleRect(quadRect)
, m_quadOpaque(true)
, m_needsBlending(false)
{
DCHECK(m_sharedQuadState);
DCHECK(m_material != Invalid);
}
gfx::Rect CCDrawQuad::opaqueRect() const
{
if (opacity() != 1)
return gfx::Rect();
if (m_sharedQuadState->opaque && m_quadOpaque)
return m_quadRect;
return m_opaqueRect;
}
void CCDrawQuad::setQuadVisibleRect(gfx::Rect quadVisibleRect)
{
m_quadVisibleRect = quadVisibleRect.Intersect(m_quadRect);
}
unsigned CCDrawQuad::size() const
{
switch (material()) {
case Checkerboard:
return sizeof(CCCheckerboardDrawQuad);
case DebugBorder:
return sizeof(CCDebugBorderDrawQuad);
case IOSurfaceContent:
return sizeof(CCIOSurfaceDrawQuad);
case TextureContent:
return sizeof(CCTextureDrawQuad);
case SolidColor:
return sizeof(CCSolidColorDrawQuad);
case TiledContent:
return sizeof(CCTileDrawQuad);
case StreamVideoContent:
return sizeof(CCStreamVideoDrawQuad);
case RenderPass:
return sizeof(CCRenderPassDrawQuad);
case YUVVideoContent:
return sizeof(CCYUVVideoDrawQuad);
case Invalid:
break;
}
CRASH();
return sizeof(CCDrawQuad);
}
scoped_ptr<CCDrawQuad> CCDrawQuad::copy(const CCSharedQuadState* copiedSharedQuadState) const
{
// RenderPass quads have their own copy() method.
DCHECK(material() != RenderPass);
unsigned bytes = size();
DCHECK(bytes > 0);
scoped_ptr<CCDrawQuad> copyQuad(reinterpret_cast<CCDrawQuad*>(new char[bytes]));
memcpy(copyQuad.get(), this, bytes);
copyQuad->setSharedQuadState(copiedSharedQuadState);
return copyQuad.Pass();
}
void CCDrawQuad::setSharedQuadState(const CCSharedQuadState* sharedQuadState)
{
m_sharedQuadState = sharedQuadState;
m_sharedQuadStateId = sharedQuadState->id;
}
}
|