Skip to content

Commit

Permalink
cc: Switch the DrawQuad enum names to chromium style and remove pragmas
Browse files Browse the repository at this point in the history
Some cleanup in the direction of making DrawQuad a chromified struct.

R=enne
BUG=152337

Review URL: https://codereview.chromium.org/11417035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168301 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
danakj@chromium.org committed Nov 16, 2012
1 parent aaf9dc1 commit e48727e
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 128 deletions.
4 changes: 2 additions & 2 deletions cc/checkerboard_draw_quad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ scoped_ptr<CheckerboardDrawQuad> CheckerboardDrawQuad::create(const SharedQuadSt
}

CheckerboardDrawQuad::CheckerboardDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, SkColor color)
: DrawQuad(sharedQuadState, DrawQuad::Checkerboard, quadRect)
: DrawQuad(sharedQuadState, DrawQuad::CHECKERBOARD, quadRect)
, m_color(color)
{
}

const CheckerboardDrawQuad* CheckerboardDrawQuad::materialCast(const DrawQuad* quad)
{
DCHECK(quad->material() == DrawQuad::Checkerboard);
DCHECK(quad->material() == DrawQuad::CHECKERBOARD);
return static_cast<const CheckerboardDrawQuad*>(quad);
}

Expand Down
4 changes: 0 additions & 4 deletions cc/checkerboard_draw_quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace cc {

#pragma pack(push, 4)

class CC_EXPORT CheckerboardDrawQuad : public DrawQuad {
public:
static scoped_ptr<CheckerboardDrawQuad> create(const SharedQuadState*, const gfx::Rect&, SkColor);
Expand All @@ -27,8 +25,6 @@ class CC_EXPORT CheckerboardDrawQuad : public DrawQuad {
SkColor m_color;
};

#pragma pack(pop)

}

#endif // CC_CHECKERBOARD_DRAW_QUAD_H_
4 changes: 2 additions & 2 deletions cc/debug_border_draw_quad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ scoped_ptr<DebugBorderDrawQuad> DebugBorderDrawQuad::create(const SharedQuadStat
}

DebugBorderDrawQuad::DebugBorderDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, SkColor color, int width)
: DrawQuad(sharedQuadState, DrawQuad::DebugBorder, quadRect)
: DrawQuad(sharedQuadState, DrawQuad::DEBUG_BORDER, quadRect)
, m_color(color)
, m_width(width)
{
Expand All @@ -25,7 +25,7 @@ DebugBorderDrawQuad::DebugBorderDrawQuad(const SharedQuadState* sharedQuadState,

const DebugBorderDrawQuad* DebugBorderDrawQuad::materialCast(const DrawQuad* quad)
{
DCHECK(quad->material() == DrawQuad::DebugBorder);
DCHECK(quad->material() == DrawQuad::DEBUG_BORDER);
return static_cast<const DebugBorderDrawQuad*>(quad);
}

Expand Down
4 changes: 0 additions & 4 deletions cc/debug_border_draw_quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace cc {

#pragma pack(push, 4)

class CC_EXPORT DebugBorderDrawQuad : public DrawQuad {
public:
static scoped_ptr<DebugBorderDrawQuad> create(const SharedQuadState*, const gfx::Rect&, SkColor, int width);
Expand All @@ -29,8 +27,6 @@ class CC_EXPORT DebugBorderDrawQuad : public DrawQuad {
int m_width;
};

#pragma pack(pop)

}

#endif // CC_DEBUG_BORDER_DRAW_QUAD_H_
2 changes: 1 addition & 1 deletion cc/delegated_renderer_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void DelegatedRendererLayerImpl::appendRenderPassQuads(QuadSink& quadSink, Appen
DCHECK(copiedSharedQuadState);

scoped_ptr<DrawQuad> copyQuad;
if (quad->material() != DrawQuad::RenderPass)
if (quad->material() != DrawQuad::RENDER_PASS)
copyQuad = quad->copy(copiedSharedQuadState);
else {
RenderPass::Id contributingDelegatedRenderPassId = RenderPassDrawQuad::materialCast(quad)->renderPassId();
Expand Down
22 changes: 11 additions & 11 deletions cc/draw_quad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ DrawQuad::DrawQuad(const SharedQuadState* sharedQuadState, Material material, co
, m_needsBlending(false)
{
DCHECK(m_sharedQuadState);
DCHECK(m_material != Invalid);
DCHECK(m_material != INVALID);
}

gfx::Rect DrawQuad::opaqueRect() const
Expand All @@ -56,32 +56,32 @@ scoped_ptr<DrawQuad> DrawQuad::copy(const SharedQuadState* copiedSharedQuadState
{
scoped_ptr<DrawQuad> copyQuad;
switch (material()) {
case Checkerboard:
case CHECKERBOARD:
copyQuad.reset(TypedCopy<CheckerboardDrawQuad>(this));
break;
case DebugBorder:
case DEBUG_BORDER:
copyQuad.reset(TypedCopy<DebugBorderDrawQuad>(this));
break;
case IOSurfaceContent:
case IO_SURFACE_CONTENT:
copyQuad.reset(TypedCopy<IOSurfaceDrawQuad>(this));
break;
case TextureContent:
case TEXTURE_CONTENT:
copyQuad.reset(TypedCopy<TextureDrawQuad>(this));
break;
case SolidColor:
case SOLID_COLOR:
copyQuad.reset(TypedCopy<SolidColorDrawQuad>(this));
break;
case TiledContent:
case TILED_CONTENT:
copyQuad.reset(TypedCopy<TileDrawQuad>(this));
break;
case StreamVideoContent:
case STREAM_VIDEO_CONTENT:
copyQuad.reset(TypedCopy<StreamVideoDrawQuad>(this));
break;
case YUVVideoContent:
case YUV_VIDEO_CONTENT:
copyQuad.reset(TypedCopy<YUVVideoDrawQuad>(this));
break;
case RenderPass: // RenderPass quads have their own copy() method.
case Invalid:
case RENDER_PASS: // RenderPass quads have their own copy() method.
case INVALID:
LOG(FATAL) << "Invalid DrawQuad material " << material();
break;
}
Expand Down
34 changes: 11 additions & 23 deletions cc/draw_quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,23 @@

namespace cc {

// WARNING! All XYZDrawQuad classes must remain PODs (plain old data).
// They are intended to be "serializable" by copying their raw bytes, so they
// must not contain any non-bit-copyable member variables!
//
// Furthermore, the class members need to be packed so they are aligned
// properly and don't have paddings/gaps, otherwise memory check tools
// like Valgrind will complain about uninitialized memory usage when
// transferring these classes over the wire.
#pragma pack(push, 4)

// DrawQuad is a bag of data used for drawing a quad. Because different
// materials need different bits of per-quad data to render, classes that derive
// from DrawQuad store additional data in their derived instance. The Material
// enum is used to "safely" downcast to the derived class.
class CC_EXPORT DrawQuad {
public:
enum Material {
Invalid,
Checkerboard,
DebugBorder,
IOSurfaceContent,
RenderPass,
TextureContent,
SolidColor,
TiledContent,
YUVVideoContent,
StreamVideoContent,
INVALID,
CHECKERBOARD,
DEBUG_BORDER,
IO_SURFACE_CONTENT,
RENDER_PASS,
TEXTURE_CONTENT,
SOLID_COLOR,
TILED_CONTENT,
YUV_VIDEO_CONTENT,
STREAM_VIDEO_CONTENT,
};

gfx::Rect quadRect() const { return m_quadRect; }
Expand All @@ -52,7 +42,7 @@ class CC_EXPORT DrawQuad {
// in will be clipped to quadRect().
void setQuadVisibleRect(gfx::Rect);
gfx::Rect quadVisibleRect() const { return m_quadVisibleRect; }
bool isDebugQuad() const { return m_material == DebugBorder; }
bool isDebugQuad() const { return m_material == DEBUG_BORDER; }

Material material() const { return m_material; }

Expand Down Expand Up @@ -86,8 +76,6 @@ class CC_EXPORT DrawQuad {
gfx::Rect m_opaqueRect;
};

#pragma pack(pop)

}

#endif // CC_DRAW_QUAD_H_
20 changes: 10 additions & 10 deletions cc/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,34 +256,34 @@ void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
GLC(m_context, m_context->disable(GL_BLEND));

switch (quad->material()) {
case DrawQuad::Invalid:
case DrawQuad::INVALID:
NOTREACHED();
break;
case DrawQuad::Checkerboard:
case DrawQuad::CHECKERBOARD:
drawCheckerboardQuad(frame, CheckerboardDrawQuad::materialCast(quad));
break;
case DrawQuad::DebugBorder:
case DrawQuad::DEBUG_BORDER:
drawDebugBorderQuad(frame, DebugBorderDrawQuad::materialCast(quad));
break;
case DrawQuad::IOSurfaceContent:
case DrawQuad::IO_SURFACE_CONTENT:
drawIOSurfaceQuad(frame, IOSurfaceDrawQuad::materialCast(quad));
break;
case DrawQuad::RenderPass:
case DrawQuad::RENDER_PASS:
drawRenderPassQuad(frame, RenderPassDrawQuad::materialCast(quad));
break;
case DrawQuad::SolidColor:
case DrawQuad::SOLID_COLOR:
drawSolidColorQuad(frame, SolidColorDrawQuad::materialCast(quad));
break;
case DrawQuad::StreamVideoContent:
case DrawQuad::STREAM_VIDEO_CONTENT:
drawStreamVideoQuad(frame, StreamVideoDrawQuad::materialCast(quad));
break;
case DrawQuad::TextureContent:
case DrawQuad::TEXTURE_CONTENT:
drawTextureQuad(frame, TextureDrawQuad::materialCast(quad));
break;
case DrawQuad::TiledContent:
case DrawQuad::TILED_CONTENT:
drawTileQuad(frame, TileDrawQuad::materialCast(quad));
break;
case DrawQuad::YUVVideoContent:
case DrawQuad::YUV_VIDEO_CONTENT:
drawYUVVideoQuad(frame, YUVVideoDrawQuad::materialCast(quad));
break;
}
Expand Down
4 changes: 2 additions & 2 deletions cc/io_surface_draw_quad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ scoped_ptr<IOSurfaceDrawQuad> IOSurfaceDrawQuad::create(const SharedQuadState* s
}

IOSurfaceDrawQuad::IOSurfaceDrawQuad(const SharedQuadState* sharedQuadState, const gfx::Rect& quadRect, const gfx::Size& ioSurfaceSize, unsigned ioSurfaceTextureId, Orientation orientation)
: DrawQuad(sharedQuadState, DrawQuad::IOSurfaceContent, quadRect)
: DrawQuad(sharedQuadState, DrawQuad::IO_SURFACE_CONTENT, quadRect)
, m_ioSurfaceSize(ioSurfaceSize)
, m_ioSurfaceTextureId(ioSurfaceTextureId)
, m_orientation(orientation)
Expand All @@ -23,7 +23,7 @@ IOSurfaceDrawQuad::IOSurfaceDrawQuad(const SharedQuadState* sharedQuadState, con

const IOSurfaceDrawQuad* IOSurfaceDrawQuad::materialCast(const DrawQuad* quad)
{
DCHECK(quad->material() == DrawQuad::IOSurfaceContent);
DCHECK(quad->material() == DrawQuad::IO_SURFACE_CONTENT);
return static_cast<const IOSurfaceDrawQuad*>(quad);
}

Expand Down
4 changes: 0 additions & 4 deletions cc/io_surface_draw_quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace cc {

#pragma pack(push, 4)

class CC_EXPORT IOSurfaceDrawQuad : public DrawQuad {
public:
enum Orientation {
Expand All @@ -36,8 +34,6 @@ class CC_EXPORT IOSurfaceDrawQuad : public DrawQuad {
Orientation m_orientation;
};

#pragma pack(pop)

}

#endif // CC_IO_SURFACE_DRAW_QUAD_H_
6 changes: 3 additions & 3 deletions cc/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static void removeRenderPassesRecursive(RenderPass::Id removeRenderPassId, Layer
QuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin();
for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) {
DrawQuad* currentQuad = (*quadListIterator);
if (currentQuad->material() != DrawQuad::RenderPass)
if (currentQuad->material() != DrawQuad::RENDER_PASS)
continue;

RenderPass::Id nextRemoveRenderPassId = RenderPassDrawQuad::materialCast(currentQuad)->renderPassId();
Expand Down Expand Up @@ -588,7 +588,7 @@ bool LayerTreeHostImpl::CullRenderPassesWithNoQuads::shouldRemoveRenderPass(cons
for (QuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin(); quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) {
DrawQuad* currentQuad = *quadListIterator;

if (currentQuad->material() != DrawQuad::RenderPass)
if (currentQuad->material() != DrawQuad::RENDER_PASS)
return false;

const RenderPass* contributingPass = findRenderPassById(RenderPassDrawQuad::materialCast(currentQuad)->renderPassId(), frame);
Expand All @@ -615,7 +615,7 @@ void LayerTreeHostImpl::removeRenderPasses(RenderPassCuller culler, FrameData& f
for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) {
DrawQuad* currentQuad = *quadListIterator;

if (currentQuad->material() != DrawQuad::RenderPass)
if (currentQuad->material() != DrawQuad::RENDER_PASS)
continue;

RenderPassDrawQuad* renderPassQuad = static_cast<RenderPassDrawQuad*>(currentQuad);
Expand Down
Loading

0 comments on commit e48727e

Please sign in to comment.