summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 06:33:19 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 06:33:19 +0000
commitb88df8febfa165c4b65cc4402db9ec51d73c3d4e (patch)
tree7db8c42ab4fa5b460134057b27fe37ded3373d23 /skia
parent16714fbe756e4744d3e40bb887e7dc0a0b3f30df (diff)
downloadchromium_src-b88df8febfa165c4b65cc4402db9ec51d73c3d4e.zip
chromium_src-b88df8febfa165c4b65cc4402db9ec51d73c3d4e.tar.gz
chromium_src-b88df8febfa165c4b65cc4402db9ec51d73c3d4e.tar.bz2
replace TestPixelRef with bitmap.allocPixels()
This is part of a larger effort to remove unnecessary subclass of pixelref from chrome/blink, to allow for faster evolution/iteration of bitmap/pixelref development in skia. BUG= Review URL: https://codereview.chromium.org/138473002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245171 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/pixel_ref_utils_unittest.cc55
1 files changed, 3 insertions, 52 deletions
diff --git a/skia/ext/pixel_ref_utils_unittest.cc b/skia/ext/pixel_ref_utils_unittest.cc
index 8a6b53f..2bfbbbe 100644
--- a/skia/ext/pixel_ref_utils_unittest.cc
+++ b/skia/ext/pixel_ref_utils_unittest.cc
@@ -24,24 +24,6 @@ namespace {
void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap);
-class TestPixelRef : public SkPixelRef {
- public:
- TestPixelRef(const SkImageInfo& info);
- virtual ~TestPixelRef();
-
- virtual SkFlattenable::Factory getFactory() const OVERRIDE;
-#ifdef SK_SUPPORT_LEGACY_ONLOCKPIXELS
- virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE;
-#endif
- virtual bool onNewLockPixels(LockRec* rec) OVERRIDE;
- virtual void onUnlockPixels() OVERRIDE {}
- virtual SkPixelRef* deepCopy(SkBitmap::Config config, const SkIRect* subset)
- OVERRIDE;
-
- private:
- scoped_ptr<char[]> pixels_;
-};
-
class TestDiscardableShader : public SkShader {
public:
TestDiscardableShader() {
@@ -76,46 +58,15 @@ class TestDiscardableShader : public SkShader {
SkBitmap bitmap_;
};
-TestPixelRef::TestPixelRef(const SkImageInfo& info)
- : SkPixelRef(info),
- pixels_(new char[4 * info.fWidth * info.fHeight]) {}
-
-TestPixelRef::~TestPixelRef() {}
-
-SkFlattenable::Factory TestPixelRef::getFactory() const { return NULL; }
-
-#ifdef SK_SUPPORT_LEGACY_ONLOCKPIXELS
-void* TestPixelRef::onLockPixels(SkColorTable** color_table) {
- return pixels_.get();
-}
-#endif
-
-bool TestPixelRef::onNewLockPixels(LockRec* rec) {
- if (pixels_.get()) {
- rec->fPixels = pixels_.get();
- rec->fColorTable = NULL;
- rec->fRowBytes = 4 * info().fWidth;
- return true;
- }
- return false;
-}
-
-SkPixelRef* TestPixelRef::deepCopy(SkBitmap::Config config,
- const SkIRect* subset) {
- this->ref();
- return this;
-}
-
void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) {
const SkImageInfo info = {
size.width(), size.height(), kPMColor_SkColorType, kPremul_SkAlphaType
};
- skia::RefPtr<TestPixelRef> pixel_ref =
- skia::AdoptRef(new TestPixelRef(info));
- pixel_ref->setURI(uri);
bitmap->setConfig(info);
- bitmap->setPixelRef(pixel_ref.get());
+ bitmap->allocPixels();
+ bitmap->pixelRef()->setImmutable();
+ bitmap->pixelRef()->setURI(uri);
}
SkCanvas* StartRecording(SkPicture* picture, gfx::Rect layer_rect) {