Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5559)

Unified Diff: cc/test/skia_common.cc

Issue 15004024: Only use skia::RefPtr for refcounting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment changes, SharePtr Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/skia_common.h ('k') | printing/pdf_metafile_skia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/skia_common.cc
diff --git a/cc/test/skia_common.cc b/cc/test/skia_common.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d3d92d8d1a0087d9a3bc1dfcfae83d95758263df
--- /dev/null
+++ b/cc/test/skia_common.cc
@@ -0,0 +1,82 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/skia_common.h"
+
+#include "cc/resources/picture.h"
+#include "skia/ext/refptr.h"
+#include "third_party/skia/include/core/SkDevice.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/skia_util.h"
+
+namespace cc {
+
+TestPixelRef::TestPixelRef(int width, int height)
+ : pixels_(new char[4 * width * height]) {}
+
+TestPixelRef::~TestPixelRef() {}
+
+SkFlattenable::Factory TestPixelRef::getFactory() { return NULL; }
+
+void* TestPixelRef::onLockPixels(SkColorTable** color_table) {
+ return pixels_.get();
+}
+
+SkPixelRef* TestPixelRef::deepCopy(
+ SkBitmap::Config config,
+ const SkIRect* subset) {
+ this->ref();
+ return this;
+}
+
+
+TestLazyPixelRef::TestLazyPixelRef(int width, int height)
+ : pixels_(new char[4 * width * height]) {}
+
+TestLazyPixelRef::~TestLazyPixelRef() {}
+
+SkFlattenable::Factory TestLazyPixelRef::getFactory() { return NULL; }
+
+void* TestLazyPixelRef::onLockPixels(SkColorTable** color_table) {
+ return pixels_.get();
+}
+
+bool TestLazyPixelRef::PrepareToDecode(const PrepareParams& params) {
+ return true;
+}
+
+SkPixelRef* TestLazyPixelRef::deepCopy(
+ SkBitmap::Config config,
+ const SkIRect* subset) {
+ this->ref();
+ return this;
+}
+
+void DrawPicture(unsigned char* buffer,
+ gfx::Rect layer_rect,
+ scoped_refptr<Picture> picture) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ layer_rect.width(),
+ layer_rect.height());
+ bitmap.setPixels(buffer);
+ SkDevice device(bitmap);
+ SkCanvas canvas(&device);
+ canvas.clipRect(gfx::RectToSkRect(layer_rect));
+ picture->Raster(&canvas, layer_rect, 1.0f, false);
+}
+
+void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) {
+ skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref =
+ skia::AdoptRef(new TestLazyPixelRef(size.width(), size.height()));
+ lazy_pixel_ref->setURI(uri);
+
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config,
+ size.width(),
+ size.height());
+ bitmap->setPixelRef(lazy_pixel_ref.get());
+}
+
+
+} // namespace cc
« no previous file with comments | « cc/test/skia_common.h ('k') | printing/pdf_metafile_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698