| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
| 9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
| 10 | 10 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 * underlying 3D API. | 590 * underlying 3D API. |
| 591 * @param flagsBitfield flags that control the flushing behavior. See | 591 * @param flagsBitfield flags that control the flushing behavior. See |
| 592 * FlushBits. | 592 * FlushBits. |
| 593 */ | 593 */ |
| 594 void flush(int flagsBitfield = 0); | 594 void flush(int flagsBitfield = 0); |
| 595 | 595 |
| 596 /** | 596 /** |
| 597 * These flags can be used with the read/write pixels functions below. | 597 * These flags can be used with the read/write pixels functions below. |
| 598 */ | 598 */ |
| 599 enum PixelOpsFlags { | 599 enum PixelOpsFlags { |
| 600 /** The GrContext will not be flushed before the surface read or write.
This means that | 600 /** The GrContext will not be flushed. This means that the read or write
may occur before |
| 601 the read or write may occur before previous draws have executed. */ | 601 previous draws have executed. */ |
| 602 kDontFlush_PixelOpsFlag = 0x1, | 602 kDontFlush_PixelOpsFlag = 0x1, |
| 603 /** Any surface writes should be flushed to the backend 3D API after the
surface operation | |
| 604 is complete */ | |
| 605 kFlushWrites_PixelOp = 0x2, | |
| 606 /** The src for write or dst read is unpremultiplied. This is only respe
cted if both the | 603 /** The src for write or dst read is unpremultiplied. This is only respe
cted if both the |
| 607 config src and dst configs are an RGBA/BGRA 8888 format. */ | 604 config src and dst configs are an RGBA/BGRA 8888 format. */ |
| 608 kUnpremul_PixelOpsFlag = 0x4, | 605 kUnpremul_PixelOpsFlag = 0x2, |
| 609 }; | 606 }; |
| 610 | 607 |
| 611 /** | 608 /** |
| 612 * Reads a rectangle of pixels from a render target. | 609 * Reads a rectangle of pixels from a render target. |
| 613 * @param target the render target to read from. NULL means the curre
nt render target. | 610 * @param target the render target to read from. NULL means the curre
nt render target. |
| 614 * @param left left edge of the rectangle to read (inclusive) | 611 * @param left left edge of the rectangle to read (inclusive) |
| 615 * @param top top edge of the rectangle to read (inclusive) | 612 * @param top top edge of the rectangle to read (inclusive) |
| 616 * @param width width of rectangle to read in pixels. | 613 * @param width width of rectangle to read in pixels. |
| 617 * @param height height of rectangle to read in pixels. | 614 * @param height height of rectangle to read in pixels. |
| 618 * @param config the pixel config of the destination buffer | 615 * @param config the pixel config of the destination buffer |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 * @return true if the write succeeded, false if not. The write can fail bec
ause of an | 688 * @return true if the write succeeded, false if not. The write can fail bec
ause of an |
| 692 * unsupported combination of texture and pixel configs. | 689 * unsupported combination of texture and pixel configs. |
| 693 */ | 690 */ |
| 694 bool writeTexturePixels(GrTexture* texture, | 691 bool writeTexturePixels(GrTexture* texture, |
| 695 int left, int top, int width, int height, | 692 int left, int top, int width, int height, |
| 696 GrPixelConfig config, const void* buffer, | 693 GrPixelConfig config, const void* buffer, |
| 697 size_t rowBytes, | 694 size_t rowBytes, |
| 698 uint32_t pixelOpsFlags = 0); | 695 uint32_t pixelOpsFlags = 0); |
| 699 | 696 |
| 700 /** | 697 /** |
| 701 * Copies a rectangle of texels from src to dst. | 698 * Copies a rectangle of texels from src to dst. The size of dst is the size
of the rectangle |
| 699 * copied and topLeft is the position of the rect in src. The rectangle is c
lipped to src's |
| 702 * bounds. | 700 * bounds. |
| 703 * @param dst the surface to copy to. | 701 * @param src the texture to copy from. |
| 704 * @param src the surface to copy from. | 702 * @param dst the render target to copy to. |
| 705 * @param srcRect the rectangle of the src that should be copied. | 703 * @param topLeft the point in src that will be copied to the top-left
of dst. If NULL, |
| 706 * @param dstPoint the translation applied when writing the srcRect's p
ixels to the dst. | 704 * (0, 0) will be used. |
| 707 * @param pixelOpsFlags see PixelOpsFlags enum above. (kUnpremul_PixelOpsFla
g is not allowed). | |
| 708 */ | 705 */ |
| 709 void copySurface(GrSurface* dst, | 706 void copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLef
t = NULL); |
| 710 GrSurface* src, | |
| 711 const SkIRect& srcRect, | |
| 712 const SkIPoint& dstPoint, | |
| 713 uint32_t pixelOpsFlags = 0); | |
| 714 | |
| 715 /** Helper that copies the whole surface but fails when the two surfaces are
not identically | |
| 716 sized. */ | |
| 717 bool copySurface(GrSurface* dst, GrSurface* src) { | |
| 718 if (NULL == dst || NULL == src || dst->width() != src->width() || | |
| 719 dst->height() != src->height()) { | |
| 720 return false; | |
| 721 } | |
| 722 this->copySurface(dst, src, SkIRect::MakeWH(dst->width(), dst->height())
, | |
| 723 SkIPoint::Make(0,0)); | |
| 724 return true; | |
| 725 } | |
| 726 | |
| 727 /** | |
| 728 * After this returns any pending writes to the surface will have been issue
d to the backend 3D API. | |
| 729 */ | |
| 730 void flushSurfaceWrites(GrSurface* surface); | |
| 731 | 707 |
| 732 /** | 708 /** |
| 733 * Resolves a render target that has MSAA. The intermediate MSAA buffer is | 709 * Resolves a render target that has MSAA. The intermediate MSAA buffer is |
| 734 * down-sampled to the associated GrTexture (accessible via | 710 * down-sampled to the associated GrTexture (accessible via |
| 735 * GrRenderTarget::asTexture()). Any pending draws to the render target will | 711 * GrRenderTarget::asTexture()). Any pending draws to the render target will |
| 736 * be executed before the resolve. | 712 * be executed before the resolve. |
| 737 * | 713 * |
| 738 * This is only necessary when a client wants to access the object directly | 714 * This is only necessary when a client wants to access the object directly |
| 739 * using the backend API directly. GrContext will detect when it must | 715 * using the backend API directly. GrContext will detect when it must |
| 740 * perform a resolve to a GrTexture used as the source of a draw or before | 716 * perform a resolve to a GrTexture used as the source of a draw or before |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1141 } |
| 1166 | 1142 |
| 1167 GrTexture* texture() { return fTexture; } | 1143 GrTexture* texture() { return fTexture; } |
| 1168 | 1144 |
| 1169 private: | 1145 private: |
| 1170 GrContext* fContext; | 1146 GrContext* fContext; |
| 1171 GrTexture* fTexture; | 1147 GrTexture* fTexture; |
| 1172 }; | 1148 }; |
| 1173 | 1149 |
| 1174 #endif | 1150 #endif |
| OLD | NEW |