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

Side by Side Diff: include/core/SkImage.h

Issue 1776693002: Add deferred texture upload API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on pixmap change Created 4 years, 9 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
« no previous file with comments | « no previous file | include/core/SkPixmap.h » ('j') | src/image/SkImage_Gpu.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef SkImage_DEFINED 8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED 9 #define SkImage_DEFINED
10 10
11 #include "SkFilterQuality.h" 11 #include "SkFilterQuality.h"
12 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
13 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
14 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
15 #include "SkScalar.h" 15 #include "SkScalar.h"
16 #include "SkShader.h" 16 #include "SkShader.h"
17 17
18 class SkData; 18 class SkData;
19 class SkCanvas; 19 class SkCanvas;
20 class SkColorTable; 20 class SkColorTable;
21 class SkImageGenerator; 21 class SkImageGenerator;
22 class SkPaint; 22 class SkPaint;
23 class SkPicture; 23 class SkPicture;
24 class SkPixelSerializer; 24 class SkPixelSerializer;
25 class SkString; 25 class SkString;
26 class SkSurface; 26 class SkSurface;
27 class GrContext; 27 class GrContext;
28 class GrContextThreadSafeProxy;
28 class GrTexture; 29 class GrTexture;
29 30
30 /** 31 /**
31 * SkImage is an abstraction for drawing a rectagle of pixels, though the 32 * SkImage is an abstraction for drawing a rectagle of pixels, though the
32 * particular type of image could be actually storing its data on the GPU, or 33 * particular type of image could be actually storing its data on the GPU, or
33 * as drawing commands (picture or PDF or otherwise), ready to be played back 34 * as drawing commands (picture or PDF or otherwise), ready to be played back
34 * into another canvas. 35 * into another canvas.
35 * 36 *
36 * The content of SkImage is always immutable, though the actual storage may 37 * The content of SkImage is always immutable, though the actual storage may
37 * change, if for example that image can be re-created via encoded data or 38 * change, if for example that image can be re-created via encoded data or
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 */ 310 */
310 SkImage* newSubset(const SkIRect& subset) const; 311 SkImage* newSubset(const SkIRect& subset) const;
311 312
312 /** 313 /**
313 * Ensures that an image is backed by a texture (when GrContext is non-null ). If no 314 * Ensures that an image is backed by a texture (when GrContext is non-null ). If no
314 * transformation is required, the returned image may be the same as this i mage. If the this 315 * transformation is required, the returned image may be the same as this i mage. If the this
315 * image is from a different GrContext, this will fail. 316 * image is from a different GrContext, this will fail.
316 */ 317 */
317 SkImage* newTextureImage(GrContext*) const; 318 SkImage* newTextureImage(GrContext*) const;
318 319
320 /** Drawing params for which a deferred texture image data should be optimiz ed. */
321 struct DeferredTextureImageUsageParams {
322 SkMatrix fViewMatrix;
reed1 2016/03/09 18:28:41 ViewMatrix is not really a term we use in the skia
bsalomon 2016/03/09 18:35:21 Sure, "CTM" or "CanvasMatrix" would work.
323 SkFilterQuality fQuality;
324 SkRect fSrcRect;
325 SkRect fDstRect;
326 };
327
328 /**
329 * This method allows clients to capture the data necessary to turn a SkImag e into a texture-
330 * backed image. If the original image is codec-backed this will decode into a format optimized
331 * for the context represented by the proxy. This method is thread safe with respect to the
332 * GrContext whence the proxy came. Clients allocate and manage the storage of the deferred
333 * texture data and control its lifetime. No cleanup is required, thus it is safe to simply free
334 * the memory out from under the data.
335 *
robertphillips 2016/03/09 18:54:16 to for -> for ?
bsalomon 2016/03/10 15:30:07 Done.
336 * The same method is used to for both getting the size necessary for pre-up loaded texture data
337 * and to retrieve the data. The params array represents the set of draws ov er which to optimize
338 * the pre-upload data.
339 *
340 * When called with a null buffer this returns the size that the client must allocate in order
341 * to create deferred texture data for this image (or zero if this is an ina ppropriate
342 * candidate). The buffer allocated by the client should be 8 byte aligned.
343 *
344 * When buffer is not null this fills in the deferred texture data for this image in the
345 * provided buffer (assuming this is an appropriate candidate image and the buffer is
346 * appropriately aligned). Upon success the size written is returned, otherw ise 0.
347 */
348 size_t getDeferredTextureImageData(const GrContextThreadSafeProxy&,
349 const DeferredTextureImageUsageParams[],
350 int paramCnt,
351 void* buffer) const;
352
353 /**
robertphillips 2016/03/09 18:54:16 produce -> produced ?
bsalomon 2016/03/10 15:30:07 Done.
354 * Returns a texture-backed image from data produce in SkImage::getDeferredT extureImageData.
355 * The context must be the context that provided the proxy passed to
356 * getDeferredTextureImageData.
357 */
358 static SkImage* NewFromDeferredTextureImageData(GrContext*, const void*, SkB udgeted);
359
319 // Helper functions to convert to SkBitmap 360 // Helper functions to convert to SkBitmap
320 361
321 enum LegacyBitmapMode { 362 enum LegacyBitmapMode {
322 kRO_LegacyBitmapMode, 363 kRO_LegacyBitmapMode,
323 kRW_LegacyBitmapMode, 364 kRW_LegacyBitmapMode,
324 }; 365 };
325 366
326 /** 367 /**
327 * Attempt to create a bitmap with the same pixels as the image. The result will always be 368 * Attempt to create a bitmap with the same pixels as the image. The result will always be
328 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s upported here). 369 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s upported here).
(...skipping 16 matching lines...) Expand all
345 386
346 private: 387 private:
347 const int fWidth; 388 const int fWidth;
348 const int fHeight; 389 const int fHeight;
349 const uint32_t fUniqueID; 390 const uint32_t fUniqueID;
350 391
351 typedef SkRefCnt INHERITED; 392 typedef SkRefCnt INHERITED;
352 }; 393 };
353 394
354 #endif 395 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPixmap.h » ('j') | src/image/SkImage_Gpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698