OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
9 #include "SkImage_Gpu.h" | 9 #include "SkImage_Gpu.h" |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!subTx) { | 179 if (!subTx) { |
180 return nullptr; | 180 return nullptr; |
181 } | 181 } |
182 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); | 182 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); |
183 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAl
phaType, subTx, | 183 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAl
phaType, subTx, |
184 fBudgeted); | 184 fBudgeted); |
185 } | 185 } |
186 | 186 |
187 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 187 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
188 | 188 |
189 #include "SkBitmapDevice.h" | |
190 #include "SkGrPixelRef.h" | 189 #include "SkGrPixelRef.h" |
191 #include "SkImageFilter.h" | 190 #include "SkImageFilter.h" |
192 | 191 |
193 class SkGpuImageFilterProxy : public SkImageFilter::Proxy { | 192 class SkGpuImageFilterProxy : public SkImageFilter::Proxy { |
194 GrContext* fCtx; | 193 GrContext* fCtx; |
195 | 194 |
196 public: | 195 public: |
197 SkGpuImageFilterProxy(GrContext* ctx) : fCtx(ctx) {} | 196 SkGpuImageFilterProxy(GrContext* ctx) : fCtx(ctx) {} |
198 | 197 |
199 SkBaseDevice* createDevice(int width, int height) override { | 198 SkBaseDevice* createDevice(int width, int height) override { |
(...skipping 20 matching lines...) Expand all Loading... |
220 return false; | 219 return false; |
221 } | 220 } |
222 }; | 221 }; |
223 | 222 |
224 SkImage* SkImage_Gpu::onApplyFilter(SkImageFilter* filter, SkIPoint* offsetResul
t, | 223 SkImage* SkImage_Gpu::onApplyFilter(SkImageFilter* filter, SkIPoint* offsetResul
t, |
225 bool forceResultToOriginalSize) const { | 224 bool forceResultToOriginalSize) const { |
226 if (!forceResultToOriginalSize || !filter->canFilterImageGPU()) { | 225 if (!forceResultToOriginalSize || !filter->canFilterImageGPU()) { |
227 return this->INHERITED::onApplyFilter(filter, offsetResult, forceResultT
oOriginalSize); | 226 return this->INHERITED::onApplyFilter(filter, offsetResult, forceResultT
oOriginalSize); |
228 } | 227 } |
229 | 228 |
230 const SkImageInfo info = make_info(this->width(), this->height(), this->isOp
aque()); | |
231 SkAutoTUnref<SkGrPixelRef> pr(new SkGrPixelRef(info, fTexture)); | |
232 SkBitmap src; | 229 SkBitmap src; |
233 src.setInfo(info); | 230 GrWrapTextureInBitmap(fTexture, this->width(), this->height(), this->isOpaqu
e(), &src); |
234 src.setPixelRef(pr, 0, 0); | |
235 | 231 |
236 GrContext* context = fTexture->getContext(); | 232 GrContext* context = fTexture->getContext(); |
237 SkGpuImageFilterProxy proxy(context); | 233 SkGpuImageFilterProxy proxy(context); |
238 SkImageFilter::Context ctx(SkMatrix::I(), | 234 SkImageFilter::Context ctx(SkMatrix::I(), |
239 SkIRect::MakeWH(this->width(), this->height()), | 235 SkIRect::MakeWH(this->width(), this->height()), |
240 SkImageFilter::Cache::Get()); | 236 SkImageFilter::Cache::Get()); |
241 | 237 |
242 SkBitmap dst; | 238 SkBitmap dst; |
243 if (filter->filterImageGPU(&proxy, src, ctx, &dst, offsetResult)) { | 239 if (filter->filterImageGPU(&proxy, src, ctx, &dst, offsetResult)) { |
244 return new SkImage_Gpu(dst.width(), dst.height(), kNeedNewImageUniqueID,
info.alphaType(), | 240 return new SkImage_Gpu(dst.width(), dst.height(), kNeedNewImageUniqueID,
dst.alphaType(), |
245 dst.getTexture(), SkSurface::kNo_Budgeted); | 241 dst.getTexture(), SkSurface::kNo_Budgeted); |
246 } | 242 } |
247 return nullptr; | 243 return nullptr; |
248 } | 244 } |
249 | 245 |
250 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 246 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
251 | 247 |
252 static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextur
eDesc& desc, | 248 static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextur
eDesc& desc, |
253 SkAlphaType at, GrWrapOwnership owner
ship, | 249 SkAlphaType at, GrWrapOwnership owner
ship, |
254 SkImage::TextureReleaseProc releasePr
oc, | 250 SkImage::TextureReleaseProc releasePr
oc, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 if (!dst) { | 385 if (!dst) { |
390 return nullptr; | 386 return nullptr; |
391 } | 387 } |
392 | 388 |
393 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 389 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
394 const SkIPoint dstP = SkIPoint::Make(0, 0); | 390 const SkIPoint dstP = SkIPoint::Make(0, 0); |
395 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); | 391 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
396 return dst; | 392 return dst; |
397 } | 393 } |
398 | 394 |
OLD | NEW |