aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-01-14 06:03:29 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-14 06:03:29 -0800
commit1de87df0b743e30619b8ba93ab0169fd41d0feae (patch)
treee6c2230c8a2922586e683035997864ebc2adc640 /src/gpu
parentabc0c8216b8e162b8de74de005f883cb84bd254b (diff)
Refactor to use GrWrapTextureInBitmap more
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrLayerHoister.cpp14
-rw-r--r--src/gpu/GrRecordReplaceDraw.cpp16
-rw-r--r--src/gpu/SkGpuDevice.cpp12
3 files changed, 12 insertions, 30 deletions
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index 2c45a7f9e5..842ab56dfb 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -12,7 +12,6 @@
#include "SkBigPicture.h"
#include "SkCanvas.h"
#include "SkGpuDevice.h"
-#include "SkGrPixelRef.h"
#include "SkLayerInfo.h"
#include "SkRecordDraw.h"
#include "SkSurface.h"
@@ -277,15 +276,6 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
}
}
-SkBitmap wrap_texture(GrTexture* texture) {
- SkASSERT(texture);
-
- SkBitmap result;
- result.setInfo(texture->surfacePriv().info(kPremul_SkAlphaType));
- result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref();
- return result;
-}
-
void GrLayerHoister::FilterLayer(GrContext* context,
SkGpuDevice* device,
const GrHoistedLayer& info) {
@@ -314,7 +304,9 @@ void GrLayerHoister::FilterLayer(GrContext* context,
SkImageFilter::Context filterContext(totMat, clipBounds, cache);
SkImageFilter::DeviceProxy proxy(device);
- const SkBitmap src = wrap_texture(layer->texture());
+ SkBitmap src;
+ GrWrapTextureInBitmap(layer->texture(), layer->texture()->width(), layer->texture()->height(),
+ false, &src);
if (!layer->filter()->filterImage(&proxy, src, filterContext, &filteredBitmap, &offset)) {
// Filtering failed. Press on with the unfiltered version.
diff --git a/src/gpu/GrRecordReplaceDraw.cpp b/src/gpu/GrRecordReplaceDraw.cpp
index 28f27dfc1c..1fe6040789 100644
--- a/src/gpu/GrRecordReplaceDraw.cpp
+++ b/src/gpu/GrRecordReplaceDraw.cpp
@@ -10,16 +10,11 @@
#include "GrRecordReplaceDraw.h"
#include "SkBigPicture.h"
#include "SkCanvasPriv.h"
-#include "SkGrPixelRef.h"
+#include "SkGr.h"
#include "SkImage.h"
#include "SkRecordDraw.h"
#include "SkRecords.h"
-static inline void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* result) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- result->setInfo(info);
- result->setPixelRef(new SkGrPixelRef(info, texture))->unref();
-}
static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canvas) {
@@ -30,10 +25,11 @@ static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
}
SkBitmap bm;
- wrap_texture(layer->texture(),
- !layer->isAtlased() ? layer->rect().width() : layer->texture()->width(),
- !layer->isAtlased() ? layer->rect().height() : layer->texture()->height(),
- &bm);
+ GrWrapTextureInBitmap(layer->texture(),
+ !layer->isAtlased() ? layer->rect().width() : layer->texture()->width(),
+ !layer->isAtlased() ? layer->rect().height() : layer->texture()->height(),
+ false,
+ &bm);
canvas->save();
canvas->setMatrix(SkMatrix::I());
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 5de1000085..a3f00c1434 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -641,13 +641,6 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
///////////////////////////////////////////////////////////////////////////////
-static SkBitmap wrap_texture(GrTexture* texture, int width, int height) {
- SkBitmap result;
- result.setInfo(SkImageInfo::MakeN32Premul(width, height));
- result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref();
- return result;
-}
-
void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
const SkPaint& paint, const SkMatrix* prePathMatrix,
bool pathIsMutable) {
@@ -1139,8 +1132,9 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
SkImageFilter::DeviceProxy proxy(this);
if (filter->canFilterImageGPU()) {
- return filter->filterImageGPU(&proxy, wrap_texture(texture, width, height),
- ctx, result, offset);
+ SkBitmap bm;
+ GrWrapTextureInBitmap(texture, width, height, false, &bm);
+ return filter->filterImageGPU(&proxy, bm, ctx, result, offset);
} else {
return false;
}