OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 GrTestTarget tt; | 77 GrTestTarget tt; |
78 context->getTestTarget(&tt); | 78 context->getTestTarget(&tt); |
79 if (NULL == tt.target()) { | 79 if (NULL == tt.target()) { |
80 SkDEBUGFAIL("Couldn't get Gr test target."); | 80 SkDEBUGFAIL("Couldn't get Gr test target."); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 GrDrawState* drawState = tt.target()->drawState(); | 84 GrDrawState* drawState = tt.target()->drawState(); |
85 | 85 |
86 SkAutoTUnref<GrTexture> texture[3]; | 86 GrTexture* texture[3]; |
87 texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], NULL)); | 87 texture[0] = GrLockAndRefCachedBitmapTexture(context, fBmp[0], NULL); |
88 texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], NULL)); | 88 texture[1] = GrLockAndRefCachedBitmapTexture(context, fBmp[1], NULL); |
89 texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2], NULL)); | 89 texture[2] = GrLockAndRefCachedBitmapTexture(context, fBmp[2], NULL); |
90 | 90 if ((NULL == texture[0]) || (NULL == texture[1]) || (NULL == texture[2])
) { |
91 if (!texture[0] || !texture[1] || !texture[2]) { | |
92 return; | 91 return; |
93 } | 92 } |
94 | 93 |
95 static const SkScalar kDrawPad = 10.f; | 94 static const SkScalar kDrawPad = 10.f; |
96 static const SkScalar kTestPad = 10.f; | 95 static const SkScalar kTestPad = 10.f; |
97 static const SkScalar kColorSpaceOffset = 64.f; | 96 static const SkScalar kColorSpaceOffset = 64.f; |
98 | 97 |
99 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa
ce; | 98 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa
ce; |
100 ++space) { | 99 ++space) { |
101 SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()), | 100 SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()), |
102 SkIntToScalar(fBmp[0].height()))
; | 101 SkIntToScalar(fBmp[0].height())); |
103 renderRect.outset(kDrawPad, kDrawPad); | 102 renderRect.outset(kDrawPad, kDrawPad); |
104 | 103 |
105 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; | 104 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; |
106 SkScalar x = kDrawPad + kTestPad; | 105 SkScalar x = kDrawPad + kTestPad; |
107 | 106 |
108 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, | 107 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0},
{2, 0, 1}, {2, 1, 0}}; |
109 {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}; | |
110 | 108 |
111 for (int i = 0; i < 6; ++i) { | 109 for (int i = 0; i < 6; ++i) { |
112 SkAutoTUnref<GrFragmentProcessor> fp( | 110 SkAutoTUnref<GrFragmentProcessor> fp( |
113 GrYUVtoRGBEffect::Create(texture[indices[i][0]], | 111 GrYUVtoRGBEffect::Create(texture[indices[i][0]], |
114 texture[indices[i][1]], | 112 texture[indices[i][1]], |
115 texture[indices[i][2]], | 113 texture[indices[i][2]], |
116 static_cast<SkYUVColorSpace>
(space))); | 114 static_cast<SkYUVColorSpace>(
space))); |
117 if (fp) { | 115 if (fp) { |
118 SkMatrix viewMatrix; | 116 SkMatrix viewMatrix; |
119 viewMatrix.setTranslate(x, y); | 117 viewMatrix.setTranslate(x, y); |
120 drawState->reset(viewMatrix); | 118 drawState->reset(viewMatrix); |
121 drawState->setRenderTarget(rt); | 119 drawState->setRenderTarget(rt); |
122 drawState->setColor(0xffffffff); | 120 drawState->setColor(0xffffffff); |
123 drawState->addColorProcessor(fp); | 121 drawState->addColorProcessor(fp); |
124 tt.target()->drawSimpleRect(renderRect); | 122 tt.target()->drawSimpleRect(renderRect); |
125 } | 123 } |
126 x += renderRect.width() + kTestPad; | 124 x += renderRect.width() + kTestPad; |
127 } | 125 } |
128 } | 126 } |
129 } | 127 |
| 128 GrUnlockAndUnrefCachedBitmapTexture(texture[0]); |
| 129 GrUnlockAndUnrefCachedBitmapTexture(texture[1]); |
| 130 GrUnlockAndUnrefCachedBitmapTexture(texture[2]); |
| 131 } |
130 | 132 |
131 private: | 133 private: |
132 SkBitmap fBmp[3]; | 134 SkBitmap fBmp[3]; |
133 | 135 |
134 typedef GM INHERITED; | 136 typedef GM INHERITED; |
135 }; | 137 }; |
136 | 138 |
137 DEF_GM( return SkNEW(YUVtoRGBEffect); ) | 139 DEF_GM( return SkNEW(YUVtoRGBEffect); ) |
138 } | 140 } |
139 | 141 |
140 #endif | 142 #endif |
OLD | NEW |