summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 17:46:55 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 17:46:55 +0000
commit1f2c8f8dc2c709e5ee4e3cfd358a6338abeb14c9 (patch)
tree4085977ccb92d9b597f86f5d46272ee728fd28bd
parent21f913ed182e5dbe0e6bfb00062b3a966a8cf3e1 (diff)
downloadchromium_src-1f2c8f8dc2c709e5ee4e3cfd358a6338abeb14c9.zip
chromium_src-1f2c8f8dc2c709e5ee4e3cfd358a6338abeb14c9.tar.gz
chromium_src-1f2c8f8dc2c709e5ee4e3cfd358a6338abeb14c9.tar.bz2
replace TestPixelRef with bitmap.allocPixels() -- removing unneeded subclass of pixelref
BUG= Review URL: https://codereview.chromium.org/136283004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244926 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/test/skia_common.cc45
-rw-r--r--cc/test/skia_common.h18
2 files changed, 5 insertions, 58 deletions
diff --git a/cc/test/skia_common.cc b/cc/test/skia_common.cc
index d52118b..dfccd64 100644
--- a/cc/test/skia_common.cc
+++ b/cc/test/skia_common.cc
@@ -6,43 +6,12 @@
#include "cc/resources/picture.h"
#include "skia/ext/refptr.h"
-#include "third_party/skia/include/core/SkBitmapDevice.h"
+#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
namespace cc {
-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 DrawPicture(unsigned char* buffer,
const gfx::Rect& layer_rect,
scoped_refptr<Picture> picture) {
@@ -51,8 +20,7 @@ void DrawPicture(unsigned char* buffer,
layer_rect.width(),
layer_rect.height());
bitmap.setPixels(buffer);
- SkBitmapDevice device(bitmap);
- SkCanvas canvas(&device);
+ SkCanvas canvas(bitmap);
canvas.clipRect(gfx::RectToSkRect(layer_rect));
picture->Raster(&canvas, NULL, layer_rect, 1.0f);
}
@@ -65,13 +33,10 @@ void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) {
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);
}
-
} // namespace cc
diff --git a/cc/test/skia_common.h b/cc/test/skia_common.h
index 3212be6..3424799 100644
--- a/cc/test/skia_common.h
+++ b/cc/test/skia_common.h
@@ -19,24 +19,6 @@ class Size;
namespace cc {
class Picture;
-class TestPixelRef : public SkPixelRef {
- public:
- explicit 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_;
-};
-
void DrawPicture(unsigned char* buffer,
const gfx::Rect& layer_rect,
scoped_refptr<Picture> picture);