Skip to content

Commit

Permalink
Always use the SkPixelRef constructor that takes SkImageInfo, as the …
Browse files Browse the repository at this point in the history
…older form is

DEPRECATED and needs to go away soon (so skia can rely on the info)

BUG=

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239832 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
reed@google.com committed Dec 10, 2013
1 parent ea24690 commit 8a945ed
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
37 changes: 26 additions & 11 deletions cc/output/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,17 @@ static SkBitmap ApplyImageFilter(GLRenderer* renderer,
skia::AdoptRef(offscreen_contexts->GrContext()->wrapBackendTexture(
backend_texture_description));

SkImageInfo info = {
source_texture_resource->size().width(),
source_texture_resource->size().height(),
kPMColor_SkColorType,
kPremul_SkAlphaType
};
// Place the platform texture inside an SkBitmap.
SkBitmap source;
source.setConfig(SkBitmap::kARGB_8888_Config,
source_texture_resource->size().width(),
source_texture_resource->size().height());
source.setConfig(info);
skia::RefPtr<SkGrPixelRef> pixel_ref =
skia::AdoptRef(new SkGrPixelRef(texture.get()));
skia::AdoptRef(new SkGrPixelRef(info, texture.get()));
source.setPixelRef(pixel_ref.get());

// Create a scratch texture for backing store.
Expand Down Expand Up @@ -591,20 +595,31 @@ static SkBitmap ApplyBlendModeWithBackdrop(
skia::AdoptRef(offscreen_contexts->GrContext()->wrapBackendTexture(
backend_texture_description));

SkImageInfo source_info = {
source_size.width(),
source_size.height(),
kPMColor_SkColorType,
kPremul_SkAlphaType
};
// Place the platform texture inside an SkBitmap.
SkBitmap source;
source.setConfig(
SkBitmap::kARGB_8888_Config, source_size.width(), source_size.height());
source.setConfig(source_info);
skia::RefPtr<SkGrPixelRef> source_pixel_ref =
skia::AdoptRef(new SkGrPixelRef(source_texture.get()));
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
};

SkBitmap background;
background.setConfig(SkBitmap::kARGB_8888_Config,
background_size.width(),
background_size.height());
background.setConfig(background_info);
skia::RefPtr<SkGrPixelRef> background_pixel_ref =
skia::AdoptRef(new SkGrPixelRef(background_texture.get()));
skia::AdoptRef(new SkGrPixelRef(
background_info, background_texture.get()));
background.setPixelRef(background_pixel_ref.get());

// Create a scratch texture for backing store.
Expand Down
9 changes: 9 additions & 0 deletions cc/resources/etc1_pixel_ref.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@

namespace cc {

#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
// Takes ownership of pixels.
ETC1PixelRef::ETC1PixelRef(scoped_ptr<uint8_t[]> pixels)
: pixels_(pixels.Pass()) {
setImmutable();
}
#endif

// Takes ownership of pixels.
ETC1PixelRef::ETC1PixelRef(const SkImageInfo& info,
scoped_ptr<uint8_t[]> pixels)
: SkPixelRef(info), pixels_(pixels.Pass()) {
setImmutable();
}

ETC1PixelRef::~ETC1PixelRef() {}

Expand Down
8 changes: 7 additions & 1 deletion cc/resources/etc1_pixel_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ namespace cc {

class CC_EXPORT ETC1PixelRef : public SkPixelRef {
public:
// Takes ownership of pixels.
#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
// DEPRECATED -- will remove once blink updates to pass info
// TODO(reed)
explicit ETC1PixelRef(scoped_ptr<uint8_t[]> pixels);
#endif

// Takes ownership of pixels.
ETC1PixelRef(const SkImageInfo& info, scoped_ptr<uint8_t[]> pixels);
virtual ~ETC1PixelRef();

// SK_DECLARE_UNFLATTENABLE_OBJECT
Expand Down
8 changes: 7 additions & 1 deletion skia/ext/lazy_pixel_ref.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

namespace skia {

LazyPixelRef::LazyPixelRef() : SkPixelRef(0) {
#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
// DEPRECATED -- will remove after blink updates to pass info
LazyPixelRef::LazyPixelRef() {
}
#endif

LazyPixelRef::LazyPixelRef(const SkImageInfo& info) : SkPixelRef(info) {
}

LazyPixelRef::~LazyPixelRef() {
Expand Down
5 changes: 5 additions & 0 deletions skia/ext/lazy_pixel_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ namespace skia {
// thread.
class SK_API LazyPixelRef : public SkPixelRef {
public:
#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
// DEPRECATED -- will remove once blink updates to pass info
LazyPixelRef();
#endif

explicit LazyPixelRef(const SkImageInfo& info);
virtual ~LazyPixelRef();

struct PrepareParams {
Expand Down

0 comments on commit 8a945ed

Please sign in to comment.