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 "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" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 return; | 234 return; |
234 } | 235 } |
235 | 236 |
236 fGrContext->flush(); | 237 fGrContext->flush(); |
237 if (callFinish) { | 238 if (callFinish) { |
238 SK_GL(*glContext, Finish()); | 239 SK_GL(*glContext, Finish()); |
239 } | 240 } |
240 #endif | 241 #endif |
241 } | 242 } |
242 | 243 |
| 244 void PictureRenderer::purgeTextures() { |
| 245 SkDiscardableMemoryPool* pool = SkGetGlobalDiscardableMemoryPool(); |
| 246 |
| 247 pool->dumpPool(); |
| 248 |
| 249 #if SK_SUPPORT_GPU |
| 250 SkGLContextHelper* glContext = this->getGLContext(); |
| 251 if (NULL == glContext) { |
| 252 SkASSERT(kBitmap_DeviceType == fDeviceType); |
| 253 return; |
| 254 } |
| 255 |
| 256 // resetState should've already done this |
| 257 fGrContext->flush(); |
| 258 |
| 259 fGrContext->purgeAllUnlockedResources(); |
| 260 #endif |
| 261 } |
| 262 |
243 uint32_t PictureRenderer::recordFlags() { | 263 uint32_t PictureRenderer::recordFlags() { |
244 return ((kNone_BBoxHierarchyType == fBBoxHierarchyType) ? 0 : | 264 return ((kNone_BBoxHierarchyType == fBBoxHierarchyType) ? 0 : |
245 SkPicture::kOptimizeForClippedPlayback_RecordingFlag) | | 265 SkPicture::kOptimizeForClippedPlayback_RecordingFlag) | |
246 SkPicture::kUsePathBoundsForClip_RecordingFlag; | 266 SkPicture::kUsePathBoundsForClip_RecordingFlag; |
247 } | 267 } |
248 | 268 |
249 /** | 269 /** |
250 * Write the canvas to the specified path. | 270 * Write the canvas to the specified path. |
251 * @param canvas Must be non-null. Canvas to be written to a file. | 271 * @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 | 272 * @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 Loading... |
926 virtual SkString getConfigNameInternal() SK_OVERRIDE { | 946 virtual SkString getConfigNameInternal() SK_OVERRIDE { |
927 return SkString("picture_clone"); | 947 return SkString("picture_clone"); |
928 } | 948 } |
929 }; | 949 }; |
930 | 950 |
931 PictureRenderer* CreatePictureCloneRenderer() { | 951 PictureRenderer* CreatePictureCloneRenderer() { |
932 return SkNEW(PictureCloneRenderer); | 952 return SkNEW(PictureCloneRenderer); |
933 } | 953 } |
934 | 954 |
935 } // namespace sk_tools | 955 } // namespace sk_tools |
OLD | NEW |