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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1429863009: Use a struct for client GL texture handles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 1 month 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
« include/gpu/gl/GrGLTypes.h ('K') | « tests/ResourceCacheTest.cpp ('k') | no next file » | 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 Google Inc. 2 * Copyright 2013 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return; 111 return;
112 } 112 }
113 113
114 // Test the wrapped factory for SkSurface by creating a backend texture and then wrap it in 114 // Test the wrapped factory for SkSurface by creating a backend texture and then wrap it in
115 // a SkSurface. 115 // a SkSurface.
116 static const int kW = 100; 116 static const int kW = 100;
117 static const int kH = 100; 117 static const int kH = 100;
118 static const uint32_t kOrigColor = 0xFFAABBCC; 118 static const uint32_t kOrigColor = 0xFFAABBCC;
119 SkAutoTArray<uint32_t> pixels(kW * kH); 119 SkAutoTArray<uint32_t> pixels(kW * kH);
120 sk_memset32(pixels.get(), kOrigColor, kW * kH); 120 sk_memset32(pixels.get(), kOrigColor, kW * kH);
121 GrBackendObject texID = gpu->createTestingOnlyBackendTexture(pixels.get(), k W, kH, 121 GrBackendObject texHandle = gpu->createTestingOnlyBackendTexture(pixels.get( ), kW, kH,
122 kRGBA_8888_GrPi xelConfig); 122 kRGBA_8888_ GrPixelConfig);
123 123
124 GrBackendTextureDesc wrappedDesc; 124 GrBackendTextureDesc wrappedDesc;
125 wrappedDesc.fConfig = kRGBA_8888_GrPixelConfig; 125 wrappedDesc.fConfig = kRGBA_8888_GrPixelConfig;
126 wrappedDesc.fWidth = kW; 126 wrappedDesc.fWidth = kW;
127 wrappedDesc.fHeight = kH; 127 wrappedDesc.fHeight = kH;
128 wrappedDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; 128 wrappedDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
129 wrappedDesc.fSampleCnt = 0; 129 wrappedDesc.fSampleCnt = 0;
130 wrappedDesc.fFlags = kRenderTarget_GrBackendTextureFlag; 130 wrappedDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
131 wrappedDesc.fTextureHandle = texID; 131 wrappedDesc.fTextureHandle = texHandle;
132 132
133 SkAutoTUnref<SkSurface> surface(SkSurface::NewWrappedRenderTarget(ctx, wrapp edDesc, nullptr)); 133 SkAutoTUnref<SkSurface> surface(SkSurface::NewWrappedRenderTarget(ctx, wrapp edDesc, nullptr));
134 REPORTER_ASSERT(reporter, surface); 134 REPORTER_ASSERT(reporter, surface);
135 if (surface) { 135 if (surface) {
136 // Validate that we can draw to the canvas and that the original texture color is preserved 136 // Validate that we can draw to the canvas and that the original texture color is preserved
137 // in pixels that aren't rendered to via the surface. 137 // in pixels that aren't rendered to via the surface.
138 SkPaint paint; 138 SkPaint paint;
139 static const SkColor kRectColor = ~kOrigColor | 0xFF000000; 139 static const SkColor kRectColor = ~kOrigColor | 0xFF000000;
140 paint.setColor(kRectColor); 140 paint.setColor(kRectColor);
141 surface->getCanvas()->drawRect(SkRect::MakeWH(SkIntToScalar(kW), SkIntTo Scalar(kH)/2), 141 surface->getCanvas()->drawRect(SkRect::MakeWH(SkIntToScalar(kW), SkIntTo Scalar(kH)/2),
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 test_image_color(reporter, refImg, expected1); 1022 test_image_color(reporter, refImg, expected1);
1023 #endif 1023 #endif
1024 test_image_color(reporter, cpyImg, expected0); 1024 test_image_color(reporter, cpyImg, expected0);
1025 1025
1026 // Now exercise the release proc 1026 // Now exercise the release proc
1027 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased); 1027 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased);
1028 refImg.reset(nullptr); // force a release of the image 1028 refImg.reset(nullptr); // force a release of the image
1029 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased); 1029 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased);
1030 } 1030 }
1031 #endif 1031 #endif
OLDNEW
« include/gpu/gl/GrGLTypes.h ('K') | « tests/ResourceCacheTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698