summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-13 23:10:25 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-13 23:10:25 +0000
commit8f7c18685dd79743fc8aa8098b7ddf139730d7cc (patch)
treebe7d4baa9b6bff50ac086cd8b4764468c7969608 /cc
parenteefe2b190e897c9a038a9fb9025a2469047cc65f (diff)
downloadchromium_src-8f7c18685dd79743fc8aa8098b7ddf139730d7cc.zip
chromium_src-8f7c18685dd79743fc8aa8098b7ddf139730d7cc.tar.gz
chromium_src-8f7c18685dd79743fc8aa8098b7ddf139730d7cc.tar.bz2
implement onNewLockPixels for SkPixelRef
BUG= Review URL: https://codereview.chromium.org/134683002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/resources/etc1_pixel_ref.cc15
-rw-r--r--cc/resources/etc1_pixel_ref.h7
-rw-r--r--cc/test/skia_common.cc12
-rw-r--r--cc/test/skia_common.h3
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc5
5 files changed, 38 insertions, 4 deletions
diff --git a/cc/resources/etc1_pixel_ref.cc b/cc/resources/etc1_pixel_ref.cc
index a113655..038e6c8 100644
--- a/cc/resources/etc1_pixel_ref.cc
+++ b/cc/resources/etc1_pixel_ref.cc
@@ -11,17 +11,30 @@ namespace cc {
// Takes ownership of pixels.
ETC1PixelRef::ETC1PixelRef(const SkImageInfo& info,
+ size_t rowBytes,
scoped_ptr<uint8_t[]> pixels)
- : SkPixelRef(info), pixels_(pixels.Pass()) {
+ : SkPixelRef(info), rowBytes_(rowBytes), pixels_(pixels.Pass()) {
setImmutable();
}
ETC1PixelRef::~ETC1PixelRef() {}
+#ifdef SK_SUPPORT_LEGACY_ONLOCKPIXELS
void* ETC1PixelRef::onLockPixels(SkColorTable** color_table) {
*color_table = NULL;
return static_cast<void*>(pixels_.get());
}
+#endif
+
+bool ETC1PixelRef::onNewLockPixels(LockRec* rec) {
+ if (pixels_.get()) {
+ rec->fPixels = pixels_.get();
+ rec->fColorTable = NULL;
+ rec->fRowBytes = rowBytes_;
+ return true;
+ }
+ return false;
+}
void ETC1PixelRef::onUnlockPixels() {}
diff --git a/cc/resources/etc1_pixel_ref.h b/cc/resources/etc1_pixel_ref.h
index 9cbb132..cf92869 100644
--- a/cc/resources/etc1_pixel_ref.h
+++ b/cc/resources/etc1_pixel_ref.h
@@ -16,7 +16,8 @@ namespace cc {
class CC_EXPORT ETC1PixelRef : public SkPixelRef {
public:
// Takes ownership of pixels.
- ETC1PixelRef(const SkImageInfo& info, scoped_ptr<uint8_t[]> pixels);
+ ETC1PixelRef(const SkImageInfo& info, size_t rowBytes,
+ scoped_ptr<uint8_t[]> pixels);
virtual ~ETC1PixelRef();
// SK_DECLARE_UNFLATTENABLE_OBJECT
@@ -24,10 +25,14 @@ class CC_EXPORT ETC1PixelRef : public SkPixelRef {
protected:
// Implementation of SkPixelRef.
+#ifdef SK_SUPPORT_LEGACY_ONLOCKPIXELS
virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE;
+#endif
+ virtual bool onNewLockPixels(LockRec* rec) OVERRIDE;
virtual void onUnlockPixels() OVERRIDE;
private:
+ size_t rowBytes_;
scoped_ptr<uint8_t[]> pixels_;
DISALLOW_COPY_AND_ASSIGN(ETC1PixelRef);
diff --git a/cc/test/skia_common.cc b/cc/test/skia_common.cc
index 27cc3c6..d52118b 100644
--- a/cc/test/skia_common.cc
+++ b/cc/test/skia_common.cc
@@ -19,9 +19,21 @@ 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,
diff --git a/cc/test/skia_common.h b/cc/test/skia_common.h
index 0d3833e..3212be6 100644
--- a/cc/test/skia_common.h
+++ b/cc/test/skia_common.h
@@ -25,7 +25,10 @@ class TestPixelRef : public SkPixelRef {
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,
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 2694d4c..a9a2720 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -5134,9 +5134,10 @@ TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) {
EXPECT_EQ(0u, context3d->NumTextures());
SkImageInfo info = {4, 4, kPMColor_SkColorType, kPremul_SkAlphaType};
- scoped_ptr<uint8_t[]> pixels(new uint8_t[8]);
+ size_t rowBytes = info.minRowBytes();
+ scoped_ptr<uint8_t[]> pixels(new uint8_t[rowBytes * info.fHeight]);
skia::RefPtr<ETC1PixelRef> etc1_pixel_ref =
- skia::AdoptRef(new ETC1PixelRef(info, pixels.Pass()));
+ skia::AdoptRef(new ETC1PixelRef(info, rowBytes, pixels.Pass()));
UIResourceBitmap bitmap(etc1_pixel_ref, gfx::Size(info.fWidth, info.fHeight));
// TODO(powel) Now that pixel_refs have info, the UIResourceBitmap
// constructor can get the can size from (pixelref->info().fWidth,