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

Unified Diff: cc/render_surface_filters.cc

Issue 11412255: cc: Use skia::RefPtr in place of raw pointers and SkAutoTUnref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref() Created 8 years 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/render_pass_unittest.cc ('k') | cc/render_surface_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/render_surface_filters.cc
diff --git a/cc/render_surface_filters.cc b/cc/render_surface_filters.cc
index 4b9a49d934e26023a8283f6d7ae0104611151a11..9fdf7274a732ff8761e45bc6d9507a87f70f9a5a 100644
--- a/cc/render_surface_filters.cc
+++ b/cc/render_surface_filters.cc
@@ -5,6 +5,7 @@
#include "cc/render_surface_filters.h"
#include "base/logging.h"
+#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/effects/SkBlurImageFilter.h"
#include "third_party/skia/include/effects/SkColorMatrixFilter.h"
@@ -246,10 +247,11 @@ public:
platformTextureDescription.fHeight = size.height();
platformTextureDescription.fConfig = kSkia8888_GrPixelConfig;
platformTextureDescription.fTextureHandle = textureId;
- SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platformTextureDescription));
+ skia::RefPtr<GrTexture> texture = skia::AdoptRef(grContext->createPlatformTexture(platformTextureDescription));
// Place the platform texture inside an SkBitmap.
m_source.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
- m_source.setPixelRef(new SkGrPixelRef(texture.get()))->unref();
+ skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(texture.get()));
+ m_source.setPixelRef(pixelRef.get());
}
~FilterBufferState() { }
@@ -265,8 +267,8 @@ public:
desc.fConfig = kSkia8888_GrPixelConfig;
for (int i = 0; i < scratchCount; ++i) {
GrAutoScratchTexture scratchTexture(m_grContext, desc, GrContext::kExact_ScratchTexMatch);
- m_scratchTextures[i].reset(scratchTexture.detach());
- if (!m_scratchTextures[i].get())
+ m_scratchTextures[i] = skia::AdoptRef(scratchTexture.detach());
+ if (!m_scratchTextures[i])
return false;
}
return true;
@@ -284,10 +286,11 @@ public:
void swap()
{
m_canvas->flush();
- m_canvas.reset(0);
- m_device.reset(0);
+ m_canvas.clear();
+ m_device.clear();
- m_source.setPixelRef(new SkGrPixelRef(m_scratchTextures[m_currentTexture].get()))->unref();
+ skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(m_scratchTextures[m_currentTexture].get()));
+ m_source.setPixelRef(pixelRef.get());
m_currentTexture = 1 - m_currentTexture;
}
@@ -295,17 +298,17 @@ private:
void createCanvas()
{
DCHECK(m_scratchTextures[m_currentTexture].get());
- m_device.reset(new SkGpuDevice(m_grContext, m_scratchTextures[m_currentTexture].get()));
- m_canvas.reset(new SkCanvas(m_device.get()));
+ m_device = skia::AdoptRef(new SkGpuDevice(m_grContext, m_scratchTextures[m_currentTexture].get()));
+ m_canvas = skia::AdoptRef(new SkCanvas(m_device.get()));
m_canvas->clear(0x0);
}
GrContext* m_grContext;
SkBitmap m_source;
- SkAutoTUnref<GrTexture> m_scratchTextures[2];
+ skia::RefPtr<GrTexture> m_scratchTextures[2];
int m_currentTexture;
- SkAutoTUnref<SkGpuDevice> m_device;
- SkAutoTUnref<SkCanvas> m_canvas;
+ skia::RefPtr<SkGpuDevice> m_device;
+ skia::RefPtr<SkCanvas> m_canvas;
};
} // namespace
@@ -381,21 +384,22 @@ SkBitmap RenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters,
switch (op.type()) {
case WebKit::WebFilterOperation::FilterTypeColorMatrix: {
SkPaint paint;
- paint.setColorFilter(new SkColorMatrixFilter(op.matrix()))->unref();
+ skia::RefPtr<SkColorMatrixFilter> filter = skia::AdoptRef(new SkColorMatrixFilter(op.matrix()));
+ paint.setColorFilter(filter.get());
canvas->drawBitmap(state.source(), 0, 0, &paint);
break;
}
case WebKit::WebFilterOperation::FilterTypeBlur: {
float stdDeviation = op.amount();
- SkAutoTUnref<SkImageFilter> filter(new SkBlurImageFilter(stdDeviation, stdDeviation));
+ skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(new SkBlurImageFilter(stdDeviation, stdDeviation));
SkPaint paint;
paint.setImageFilter(filter.get());
canvas->drawSprite(state.source(), 0, 0, &paint);
break;
}
case WebKit::WebFilterOperation::FilterTypeDropShadow: {
- SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(op.amount(), op.amount()));
- SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(op.dropShadowColor(), SkXfermode::kSrcIn_Mode));
+ skia::RefPtr<SkImageFilter> blurFilter = skia::AdoptRef(new SkBlurImageFilter(op.amount(), op.amount()));
+ skia::RefPtr<SkColorFilter> colorFilter = skia::AdoptRef(SkColorFilter::CreateModeFilter(op.dropShadowColor(), SkXfermode::kSrcIn_Mode));
SkPaint paint;
paint.setImageFilter(blurFilter.get());
paint.setColorFilter(colorFilter.get());
@@ -408,7 +412,7 @@ SkBitmap RenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters,
}
case WebKit::WebFilterOperation::FilterTypeZoom: {
SkPaint paint;
- SkAutoTUnref<SkImageFilter> zoomFilter(
+ skia::RefPtr<SkImageFilter> zoomFilter = skia::AdoptRef(
new SkMagnifierImageFilter(
SkRect::MakeXYWH(op.zoomRect().x,
op.zoomRect().y,
« no previous file with comments | « cc/render_pass_unittest.cc ('k') | cc/render_surface_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698