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

Side by Side Diff: tools/PictureRenderer.cpp

Issue 117583002: Update bench pictures to time image decode & upload costs (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: More clean up Created 7 years 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
OLDNEW
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 "PictureRenderer.h" 8 #include "PictureRenderer.h"
9 #include "picture_utils.h" 9 #include "picture_utils.h"
10 #include "SamplePipeControllers.h" 10 #include "SamplePipeControllers.h"
11 #include "SkBitmapHasher.h" 11 #include "SkBitmapHasher.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkData.h" 13 #include "SkData.h"
14 #include "SkDevice.h" 14 #include "SkDevice.h"
15 #include "SkDiscardableMemoryPool.h"
15 #include "SkGPipe.h" 16 #include "SkGPipe.h"
16 #if SK_SUPPORT_GPU 17 #if SK_SUPPORT_GPU
17 #include "gl/GrGLDefines.h" 18 #include "gl/GrGLDefines.h"
18 #include "SkGpuDevice.h" 19 #include "SkGpuDevice.h"
19 #endif 20 #endif
20 #include "SkGraphics.h" 21 #include "SkGraphics.h"
21 #include "SkImageEncoder.h" 22 #include "SkImageEncoder.h"
22 #include "SkMaskFilter.h" 23 #include "SkMaskFilter.h"
23 #include "SkMatrix.h" 24 #include "SkMatrix.h"
24 #include "SkPicture.h" 25 #include "SkPicture.h"
25 #include "SkPictureUtils.h" 26 #include "SkPictureUtils.h"
26 #include "SkPixelRef.h" 27 #include "SkPixelRef.h"
27 #include "SkRTree.h" 28 #include "SkRTree.h"
28 #include "SkScalar.h" 29 #include "SkScalar.h"
29 #include "SkStream.h" 30 #include "SkStream.h"
30 #include "SkString.h" 31 #include "SkString.h"
31 #include "SkTemplates.h" 32 #include "SkTemplates.h"
32 #include "SkTileGridPicture.h" 33 #include "SkTileGridPicture.h"
33 #include "SkTDArray.h" 34 #include "SkTDArray.h"
34 #include "SkThreadUtils.h" 35 #include "SkThreadUtils.h"
35 #include "SkTypes.h" 36 #include "SkTypes.h"
36 37
38 class SkTools_PictureRenderer {
39 private:
40 static void PurgeAllUnlockedTextures(GrContext* context) {
41 context->purgeAllUnlocked();
42 }
43
44 friend class sk_tools::PictureRenderer;
45 };
46
37 namespace sk_tools { 47 namespace sk_tools {
38 48
39 enum { 49 enum {
40 kDefaultTileWidth = 256, 50 kDefaultTileWidth = 256,
41 kDefaultTileHeight = 256 51 kDefaultTileHeight = 256
42 }; 52 };
43 53
44 /* TODO(epoger): These constants are already maintained in 2 other places: 54 /* TODO(epoger): These constants are already maintained in 2 other places:
45 * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place . 55 * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place .
46 * Figure out a way to share the definitions instead. 56 * Figure out a way to share the definitions instead.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 return; 243 return;
234 } 244 }
235 245
236 fGrContext->flush(); 246 fGrContext->flush();
237 if (callFinish) { 247 if (callFinish) {
238 SK_GL(*glContext, Finish()); 248 SK_GL(*glContext, Finish());
239 } 249 }
240 #endif 250 #endif
241 } 251 }
242 252
253 void PictureRenderer::purgeTextures() {
254 SkDiscardableMemoryPool* pool = SkGetGlobalDiscardableMemoryPool();
255
256 pool->dumpPool();
257
258 #if SK_SUPPORT_GPU
259 SkGLContextHelper* glContext = this->getGLContext();
260 if (NULL == glContext) {
261 SkASSERT(kBitmap_DeviceType == fDeviceType);
262 return;
263 }
264
265 // resetState should've already done this
266 fGrContext->flush();
267
268 SkTools_PictureRenderer::PurgeAllUnlockedTextures(fGrContext);
269 #endif
270 }
271
243 uint32_t PictureRenderer::recordFlags() { 272 uint32_t PictureRenderer::recordFlags() {
244 return ((kNone_BBoxHierarchyType == fBBoxHierarchyType) ? 0 : 273 return ((kNone_BBoxHierarchyType == fBBoxHierarchyType) ? 0 :
245 SkPicture::kOptimizeForClippedPlayback_RecordingFlag) | 274 SkPicture::kOptimizeForClippedPlayback_RecordingFlag) |
246 SkPicture::kUsePathBoundsForClip_RecordingFlag; 275 SkPicture::kUsePathBoundsForClip_RecordingFlag;
247 } 276 }
248 277
249 /** 278 /**
250 * Write the canvas to the specified path. 279 * Write the canvas to the specified path.
251 * @param canvas Must be non-null. Canvas to be written to a file. 280 * @param canvas Must be non-null. Canvas to be written to a file.
252 * @param path Path for the file to be written. Should have no extension; write( ) will append 281 * @param path Path for the file to be written. Should have no extension; write( ) will append
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 virtual SkString getConfigNameInternal() SK_OVERRIDE { 955 virtual SkString getConfigNameInternal() SK_OVERRIDE {
927 return SkString("picture_clone"); 956 return SkString("picture_clone");
928 } 957 }
929 }; 958 };
930 959
931 PictureRenderer* CreatePictureCloneRenderer() { 960 PictureRenderer* CreatePictureCloneRenderer() {
932 return SkNEW(PictureCloneRenderer); 961 return SkNEW(PictureCloneRenderer);
933 } 962 }
934 963
935 } // namespace sk_tools 964 } // namespace sk_tools
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698