Skip to content

Commit

Permalink
cc: Remove unnecessary "default" cases from switch statements.
Browse files Browse the repository at this point in the history
Makes all cc/ code consistent and improves compile time error
checking when adding new enums.

TEST=compile,cc_unittests
BUG=277861

Review URL: https://chromiumcodereview.appspot.com/22875045

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219691 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
reveman@chromium.org committed Aug 27, 2013
1 parent 979d318 commit f28d64d
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 45 deletions.
8 changes: 7 additions & 1 deletion cc/animation/transform_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <cmath>
#include <limits>

#include "base/logging.h"
#include "cc/animation/transform_operation.h"
#include "ui/gfx/box_f.h"
#include "ui/gfx/vector3d_f.h"
Expand Down Expand Up @@ -293,9 +294,14 @@ bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box,
case TransformOperation::TransformOperationIdentity:
*bounds = box;
return true;
default:
case TransformOperation::TransformOperationRotate:
case TransformOperation::TransformOperationSkew:
case TransformOperation::TransformOperationPerspective:
case TransformOperation::TransformOperationMatrix:
return false;
}
NOTREACHED();
return false;
}

} // namespace cc
12 changes: 7 additions & 5 deletions cc/layers/picture_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,

const ManagedTileState::TileVersion& tile_version =
iter->GetTileVersionForDrawing();
scoped_ptr<DrawQuad> draw_quad;
switch (tile_version.mode()) {
case ManagedTileState::TileVersion::RESOURCE_MODE: {
gfx::RectF texture_rect = iter.texture_rect();
Expand All @@ -244,7 +245,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
texture_rect,
iter.texture_size(),
tile_version.contents_swizzled());
quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
draw_quad = quad.PassAs<DrawQuad>();
break;
}
case ManagedTileState::TileVersion::PICTURE_PILE_MODE: {
Expand All @@ -267,7 +268,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
iter->contents_scale(),
draw_direct_to_backbuffer,
pile_);
quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
draw_quad = quad.PassAs<DrawQuad>();
break;
}
case ManagedTileState::TileVersion::SOLID_COLOR_MODE: {
Expand All @@ -276,13 +277,14 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
geometry_rect,
tile_version.get_solid_color(),
false);
quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
draw_quad = quad.PassAs<DrawQuad>();
break;
}
default:
NOTREACHED();
}

DCHECK(draw_quad);
quad_sink->Append(draw_quad.Pass(), append_quads_data);

if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
seen_tilings.push_back(iter.CurrentTiling());
}
Expand Down
8 changes: 4 additions & 4 deletions cc/output/filter_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ static FilterOperation CreateNoOpFilter(FilterOperation::FilterType type) {
return FilterOperation::CreateZoomFilter(1.f, 0);
case FilterOperation::SATURATING_BRIGHTNESS:
return FilterOperation::CreateSaturatingBrightnessFilter(0.f);
default:
NOTREACHED();
return FilterOperation::CreateEmptyFilter();
}
NOTREACHED();
return FilterOperation::CreateEmptyFilter();
}

static float ClampAmountForFilterType(float amount,
Expand All @@ -173,10 +172,11 @@ static float ClampAmountForFilterType(float amount,
case FilterOperation::SATURATING_BRIGHTNESS:
return amount;
case FilterOperation::COLOR_MATRIX:
default:
NOTREACHED();
return amount;
}
NOTREACHED();
return amount;
}

// static
Expand Down
29 changes: 25 additions & 4 deletions cc/output/filter_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,16 @@ bool FilterOperations::HasFilterThatMovesPixels() const {
case FilterOperation::DROP_SHADOW:
case FilterOperation::ZOOM:
return true;
default:
case FilterOperation::OPACITY:
case FilterOperation::COLOR_MATRIX:
case FilterOperation::GRAYSCALE:
case FilterOperation::SEPIA:
case FilterOperation::SATURATE:
case FilterOperation::HUE_ROTATE:
case FilterOperation::INVERT:
case FilterOperation::BRIGHTNESS:
case FilterOperation::CONTRAST:
case FilterOperation::SATURATING_BRIGHTNESS:
break;
}
}
Expand All @@ -104,10 +113,22 @@ bool FilterOperations::HasFilterThatAffectsOpacity() const {
return true;
case FilterOperation::COLOR_MATRIX: {
const SkScalar* matrix = op.matrix();
return matrix[15] || matrix[16] || matrix[17] || matrix[18] != 1 ||
matrix[19];
if (matrix[15] ||
matrix[16] ||
matrix[17] ||
matrix[18] != 1 ||
matrix[19])
return true;
break;
}
default:
case FilterOperation::GRAYSCALE:
case FilterOperation::SEPIA:
case FilterOperation::SATURATE:
case FilterOperation::HUE_ROTATE:
case FilterOperation::INVERT:
case FilterOperation::BRIGHTNESS:
case FilterOperation::CONTRAST:
case FilterOperation::SATURATING_BRIGHTNESS:
break;
}
}
Expand Down
6 changes: 5 additions & 1 deletion cc/output/render_surface_filters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,13 @@ bool GetColorMatrix(const FilterOperation& op, SkScalar matrix[20]) {
memcpy(matrix, op.matrix(), sizeof(SkScalar[20]));
return true;
}
default:
case FilterOperation::BLUR:
case FilterOperation::DROP_SHADOW:
case FilterOperation::ZOOM:
return false;
}
NOTREACHED();
return false;
}

class FilterBufferState {
Expand Down
5 changes: 2 additions & 3 deletions cc/resources/managed_tile_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ bool ManagedTileState::TileVersion::IsReadyToDraw() const {
case SOLID_COLOR_MODE:
case PICTURE_PILE_MODE:
return true;
default:
NOTREACHED();
return false;
}
NOTREACHED();
return false;
}

size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const {
Expand Down
3 changes: 1 addition & 2 deletions cc/resources/managed_tile_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class CC_EXPORT ManagedTileState {
enum Mode {
RESOURCE_MODE,
SOLID_COLOR_MODE,
PICTURE_PILE_MODE,
NUM_MODES
PICTURE_PILE_MODE
};

TileVersion();
Expand Down
20 changes: 8 additions & 12 deletions cc/resources/platform_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,16 @@ class PlatformColor {

// Returns the most efficient texture format for this platform.
static GLenum BestTextureFormat(bool supports_bgra8888) {
GLenum texture_format = GL_RGBA;
switch (Format()) {
case SOURCE_FORMAT_RGBA8:
break;
case SOURCE_FORMAT_BGRA8:
if (supports_bgra8888)
texture_format = GL_BGRA_EXT;
break;
default:
NOTREACHED();
break;
return GL_BGRA_EXT;
return GL_RGBA;
case SOURCE_FORMAT_RGBA8:
return GL_RGBA;
}
return texture_format;
NOTREACHED();
return GL_RGBA;
}

// Return true if the given texture format has the same component order
Expand All @@ -49,10 +46,9 @@ class PlatformColor {
return texture_format == GL_RGBA;
case SOURCE_FORMAT_BGRA8:
return texture_format == GL_BGRA_EXT;
default:
NOTREACHED();
return false;
}
NOTREACHED();
return false;
}

private:
Expand Down
1 change: 0 additions & 1 deletion cc/resources/raster_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ scoped_ptr<base::Value> RasterModeAsValue(RasterMode raster_mode) {
case LOW_QUALITY_RASTER_MODE:
return scoped_ptr<base::Value>(
base::Value::CreateStringValue("LOW_QUALITY_RASTER_MODE"));
case NUM_RASTER_MODES:
default:
NOTREACHED() << "Unrecognized RasterMode value " << raster_mode;
return scoped_ptr<base::Value>(
Expand Down
14 changes: 6 additions & 8 deletions cc/resources/tile_priority.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@ scoped_ptr<base::Value> TileResolutionAsValue(
case NON_IDEAL_RESOLUTION:
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"NON_IDEAL_RESOLUTION"));
default:
DCHECK(false) << "Unrecognized TileResolution value " << resolution;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown TileResolution value>"));
}
DCHECK(false) << "Unrecognized TileResolution value " << resolution;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown TileResolution value>"));
}

scoped_ptr<base::Value> TilePriority::AsValue() const {
Expand Down Expand Up @@ -176,11 +175,10 @@ scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) {
case NEW_CONTENT_TAKES_PRIORITY:
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"NEW_CONTENT_TAKES_PRIORITY"));
default:
DCHECK(false) << "Unrecognized priority value " << prio;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown>"));
}
DCHECK(false) << "Unrecognized priority value " << prio;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown>"));
}

scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const {
Expand Down
3 changes: 0 additions & 3 deletions cc/trees/layer_tree_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,6 @@ void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events,
case AnimationEvent::PropertyUpdate:
(*iter).second->NotifyAnimationPropertyUpdate((*events)[event_index]);
break;

default:
NOTREACHED();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/layer_tree_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void LayerTreeImpl::ProcessUIResourceRequestQueue() {
case UIResourceRequest::UIResourceDelete:
layer_tree_host_impl_->DeleteUIResource(req.id);
break;
default:
case UIResourceRequest::UIResourceInvalidRequest:
NOTREACHED();
break;
}
Expand Down

0 comments on commit f28d64d

Please sign in to comment.