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

Side by Side Diff: src/core/SkImageFilterUtils.cpp

Issue 30593003: Apply matrix early in draw bitmap (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add flattenable registration for local image filter subclass to fix GM serialization failure Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Android Open Source Project 2 * Copyright 2013 The Android Open Source Project
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 "SkMatrix.h" 8 #include "SkMatrix.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 #include "GrTexture.h" 11 #include "GrTexture.h"
12 #include "SkImageFilterUtils.h" 12 #include "SkImageFilterUtils.h"
13 #include "SkBitmap.h" 13 #include "SkBitmap.h"
14 #include "SkGrPixelRef.h" 14 #include "SkGrPixelRef.h"
15 #include "SkGr.h" 15 #include "SkGr.h"
16 16
17 bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) { 17 bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
18 result->setConfig(SkBitmap::kARGB_8888_Config, width, height); 18 result->setConfig(SkBitmap::kARGB_8888_Config, width, height);
19 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref(); 19 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref();
20 return true; 20 return true;
21 } 21 }
22 22
23 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter: :Proxy* proxy, 23 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter: :Proxy* proxy,
24 const SkBitmap& src, const SkMatrix& ctm, 24 const SkBitmap& src, const SkMatrix& ctm,
25 SkBitmap* result, SkIPoint* offset) { 25 SkBitmap* result, SkIPoint* offset) {
26 // Ensure that GrContext calls under filterImage and filterImageGPU below wi ll see an identity
27 // matrix with no clip and that the matrix, clip, and render target set befo re this function was
28 // called are restored before we return to the caller.
29 GrContext* context = src.getTexture()->getContext();
30 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL);
26 if (!filter) { 31 if (!filter) {
27 *result = src; 32 *result = src;
28 return true; 33 return true;
29 } else if (filter->canFilterImageGPU()) { 34 } else if (filter->canFilterImageGPU()) {
30 return filter->filterImageGPU(proxy, src, ctm, result, offset); 35 return filter->filterImageGPU(proxy, src, ctm, result, offset);
31 } else { 36 } else {
32 if (filter->filterImage(proxy, src, ctm, result, offset)) { 37 if (filter->filterImage(proxy, src, ctm, result, offset)) {
33 if (!result->getTexture()) { 38 if (!result->getTexture()) {
34 GrContext* context = ((GrTexture *) src.getTexture())->getContex t(); 39 GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context, *result, NULL);
35 GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context,
36 *result, NULL);
37 result->setPixelRef(new SkGrPixelRef(resultTex))->unref(); 40 result->setPixelRef(new SkGrPixelRef(resultTex))->unref();
38 GrUnlockAndUnrefCachedBitmapTexture(resultTex); 41 GrUnlockAndUnrefCachedBitmapTexture(resultTex);
39 } 42 }
40 return true; 43 return true;
41 } else { 44 } else {
42 return false; 45 return false;
43 } 46 }
44 } 47 }
45 } 48 }
46 #endif 49 #endif
OLDNEW
« no previous file with comments | « include/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698