Skip to content

Commit

Permalink
setConfig is deprecated, use setInfo or allocPixels instead
Browse files Browse the repository at this point in the history
kPMColor_SkColorType -> kN32_SkColorType

BUG=skia:2706

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280689 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
reed@google.com committed Jun 30, 2014
1 parent 5c1848e commit 6d23291
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 42 deletions.
2 changes: 1 addition & 1 deletion cc/layers/heads_up_display_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
const void* pixels = hud_canvas_->peekPixels(&info, &row_bytes);
DCHECK(pixels);
gfx::Rect content_rect(content_bounds());
DCHECK(info.colorType() == kPMColor_SkColorType);
DCHECK(info.colorType() == kN32_SkColorType);
resource_provider->SetPixels(hud_resource_->id(),
static_cast<const uint8_t*>(pixels),
content_rect,
Expand Down
25 changes: 7 additions & 18 deletions cc/output/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,9 @@ static SkBitmap ApplyImageFilter(
skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
backend_texture_description));

SkImageInfo info = {
source_texture_resource->size().width(),
source_texture_resource->size().height(),
kPMColor_SkColorType,
kPremul_SkAlphaType
};
SkImageInfo info =
SkImageInfo::MakeN32Premul(source_texture_resource->size().width(),
source_texture_resource->size().height());
// Place the platform texture inside an SkBitmap.
SkBitmap source;
source.setInfo(info);
Expand Down Expand Up @@ -741,25 +738,17 @@ static SkBitmap ApplyBlendModeWithBackdrop(
skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
backend_texture_description));

SkImageInfo source_info = {
source_size.width(),
source_size.height(),
kPMColor_SkColorType,
kPremul_SkAlphaType
};
SkImageInfo source_info =
SkImageInfo::MakeN32Premul(source_size.width(), source_size.height());
// Place the platform texture inside an SkBitmap.
SkBitmap source;
source.setInfo(source_info);
skia::RefPtr<SkGrPixelRef> source_pixel_ref =
skia::AdoptRef(new SkGrPixelRef(source_info, source_texture.get()));
source.setPixelRef(source_pixel_ref.get());

SkImageInfo background_info = {
background_size.width(),
background_size.height(),
kPMColor_SkColorType,
kPremul_SkAlphaType
};
SkImageInfo background_info = SkImageInfo::MakeN32Premul(
background_size.width(), background_size.height());

SkBitmap background;
background.setInfo(background_info);
Expand Down
5 changes: 2 additions & 3 deletions cc/output/software_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,8 @@ void SoftwareRenderer::CopyCurrentRenderPassToBitmap(
gfx::Rect window_copy_rect = MoveFromDrawToWindowSpace(copy_rect);

scoped_ptr<SkBitmap> bitmap(new SkBitmap);
bitmap->setConfig(SkBitmap::kARGB_8888_Config,
window_copy_rect.width(),
window_copy_rect.height());
bitmap->setInfo(SkImageInfo::MakeN32Premul(window_copy_rect.width(),
window_copy_rect.height()));
current_canvas_->readPixels(
bitmap.get(), window_copy_rect.x(), window_copy_rect.y());

Expand Down
12 changes: 3 additions & 9 deletions cc/output/software_renderer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,11 @@ TEST_F(SoftwareRendererTest, TileQuad) {
RGBA_8888);

SkBitmap yellow_tile;
yellow_tile.setConfig(
SkBitmap::kARGB_8888_Config, outer_size.width(), outer_size.height());
yellow_tile.allocPixels();
yellow_tile.allocN32Pixels(outer_size.width(), outer_size.height());
yellow_tile.eraseColor(SK_ColorYELLOW);

SkBitmap cyan_tile;
cyan_tile.setConfig(
SkBitmap::kARGB_8888_Config, inner_size.width(), inner_size.height());
cyan_tile.allocPixels();
cyan_tile.allocN32Pixels(inner_size.width(), inner_size.height());
cyan_tile.eraseColor(SK_ColorCYAN);

resource_provider()->SetPixels(
Expand Down Expand Up @@ -254,9 +250,7 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) {
RGBA_8888);

SkBitmap cyan_tile; // The lowest five rows are yellow.
cyan_tile.setConfig(
SkBitmap::kARGB_8888_Config, tile_size.width(), tile_size.height());
cyan_tile.allocPixels();
cyan_tile.allocN32Pixels(tile_size.width(), tile_size.height());
cyan_tile.eraseColor(SK_ColorCYAN);
cyan_tile.eraseArea(
SkIRect::MakeLTRB(
Expand Down
2 changes: 1 addition & 1 deletion cc/resources/bitmap_skpicture_content_layer_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void BitmapSkPictureContentLayerUpdater::Resource::Update(
SkAlphaType at =
updater_->layer_is_opaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
bitmap_.allocPixels(SkImageInfo::Make(
source_rect.width(), source_rect.height(), kPMColor_SkColorType, at));
source_rect.width(), source_rect.height(), kN32_SkColorType, at));
SkCanvas canvas(bitmap_);
updater_->PaintContentsRect(&canvas, source_rect);

Expand Down
3 changes: 1 addition & 2 deletions cc/resources/picture_pile_impl_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class PicturePileImplPerfTest : public testing::Test {
gfx::Rect content_rect(0, 0, kTileSize, kTileSize);

SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
bitmap.allocPixels();
bitmap.allocN32Pixels(1, 1);
SkCanvas canvas(bitmap);

FakeRenderingStatsInstrumentation rendering_stats_instrumentation;
Expand Down
5 changes: 1 addition & 4 deletions cc/resources/picture_pile_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,7 @@ TEST_P(OverlapTest, NoOverlap) {
gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));

SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
content_bounds.width(),
content_bounds.height());
bitmap.allocPixels();
bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
SkCanvas canvas(bitmap);

FakeRenderingStatsInstrumentation rendering_stats_instrumentation;
Expand Down
4 changes: 2 additions & 2 deletions cc/resources/resource_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ SkColorType ResourceFormatToSkColorType(ResourceFormat format) {
return kARGB_4444_SkColorType;
case RGBA_8888:
case BGRA_8888:
return kPMColor_SkColorType;
return kN32_SkColorType;
case ETC1:
case LUMINANCE_8:
case RGB_565:
NOTREACHED();
break;
}
NOTREACHED();
return kPMColor_SkColorType;
return kN32_SkColorType;
}

} // namespace cc
2 changes: 1 addition & 1 deletion cc/resources/ui_resource_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
}

UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) {
DCHECK_EQ(skbitmap.colorType(), kPMColor_SkColorType);
DCHECK_EQ(skbitmap.colorType(), kN32_SkColorType);
DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels());
DCHECK(skbitmap.isImmutable());

Expand Down
2 changes: 1 addition & 1 deletion cc/test/layer_tree_pixel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture(
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

DCHECK_EQ(kPMColor_SkColorType, bitmap.colorType());
DCHECK_EQ(kN32_SkColorType, bitmap.colorType());

{
SkAutoLockPixels lock(bitmap);
Expand Down

0 comments on commit 6d23291

Please sign in to comment.