| 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. This means that the read or write
may occur before | 600 /** The GrContext will not be flushed before the surface read or write.
This means that |
| 601 previous draws have executed. */ | 601 the read or write may occur before 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, |
| 603 /** The src for write or dst read is unpremultiplied. This is only respe
cted if both the | 606 /** The src for write or dst read is unpremultiplied. This is only respe
cted if both the |
| 604 config src and dst configs are an RGBA/BGRA 8888 format. */ | 607 config src and dst configs are an RGBA/BGRA 8888 format. */ |
| 605 kUnpremul_PixelOpsFlag = 0x2, | 608 kUnpremul_PixelOpsFlag = 0x4, |
| 606 }; | 609 }; |
| 607 | 610 |
| 608 /** | 611 /** |
| 609 * Reads a rectangle of pixels from a render target. | 612 * Reads a rectangle of pixels from a render target. |
| 610 * @param target the render target to read from. NULL means the curre
nt render target. | 613 * @param target the render target to read from. NULL means the curre
nt render target. |
| 611 * @param left left edge of the rectangle to read (inclusive) | 614 * @param left left edge of the rectangle to read (inclusive) |
| 612 * @param top top edge of the rectangle to read (inclusive) | 615 * @param top top edge of the rectangle to read (inclusive) |
| 613 * @param width width of rectangle to read in pixels. | 616 * @param width width of rectangle to read in pixels. |
| 614 * @param height height of rectangle to read in pixels. | 617 * @param height height of rectangle to read in pixels. |
| 615 * @param config the pixel config of the destination buffer | 618 * @param config the pixel config of the destination buffer |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 * @return true if the write succeeded, false if not. The write can fail bec
ause of an | 691 * @return true if the write succeeded, false if not. The write can fail bec
ause of an |
| 689 * unsupported combination of texture and pixel configs. | 692 * unsupported combination of texture and pixel configs. |
| 690 */ | 693 */ |
| 691 bool writeTexturePixels(GrTexture* texture, | 694 bool writeTexturePixels(GrTexture* texture, |
| 692 int left, int top, int width, int height, | 695 int left, int top, int width, int height, |
| 693 GrPixelConfig config, const void* buffer, | 696 GrPixelConfig config, const void* buffer, |
| 694 size_t rowBytes, | 697 size_t rowBytes, |
| 695 uint32_t pixelOpsFlags = 0); | 698 uint32_t pixelOpsFlags = 0); |
| 696 | 699 |
| 697 /** | 700 /** |
| 698 * Copies a rectangle of texels from src to dst. The size of dst is the size
of the rectangle | 701 * Copies a rectangle of texels from src to dst. |
| 699 * copied and topLeft is the position of the rect in src. The rectangle is c
lipped to src's | |
| 700 * bounds. | 702 * bounds. |
| 701 * @param src the texture to copy from. | 703 * @param dst the surface to copy to. |
| 702 * @param dst the render target to copy to. | 704 * @param src the surface to copy from. |
| 703 * @param topLeft the point in src that will be copied to the top-left
of dst. If NULL, | 705 * @param srcRect the rectangle of the src that should be copied. |
| 704 * (0, 0) will be used. | 706 * @param dstPoint the translation applied when writing the srcRect's p
ixels to the dst. |
| 707 * @param pixelOpsFlags see PixelOpsFlags enum above. (kUnpremul_PixelOpsFla
g is not allowed). |
| 705 */ | 708 */ |
| 706 void copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLef
t = NULL); | 709 void copySurface(GrSurface* dst, |
| 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); |
| 707 | 731 |
| 708 /** | 732 /** |
| 709 * Resolves a render target that has MSAA. The intermediate MSAA buffer is | 733 * Resolves a render target that has MSAA. The intermediate MSAA buffer is |
| 710 * down-sampled to the associated GrTexture (accessible via | 734 * down-sampled to the associated GrTexture (accessible via |
| 711 * GrRenderTarget::asTexture()). Any pending draws to the render target will | 735 * GrRenderTarget::asTexture()). Any pending draws to the render target will |
| 712 * be executed before the resolve. | 736 * be executed before the resolve. |
| 713 * | 737 * |
| 714 * This is only necessary when a client wants to access the object directly | 738 * This is only necessary when a client wants to access the object directly |
| 715 * using the backend API directly. GrContext will detect when it must | 739 * using the backend API directly. GrContext will detect when it must |
| 716 * perform a resolve to a GrTexture used as the source of a draw or before | 740 * 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... |
| 1141 } | 1165 } |
| 1142 | 1166 |
| 1143 GrTexture* texture() { return fTexture; } | 1167 GrTexture* texture() { return fTexture; } |
| 1144 | 1168 |
| 1145 private: | 1169 private: |
| 1146 GrContext* fContext; | 1170 GrContext* fContext; |
| 1147 GrTexture* fTexture; | 1171 GrTexture* fTexture; |
| 1148 }; | 1172 }; |
| 1149 | 1173 |
| 1150 #endif | 1174 #endif |
| OLD | NEW |