41 public SWPresentable(PresentableState pState, SWResourceFactory factory) { 42 super(factory, pState.getRenderWidth(), pState.getRenderHeight()); 43 this.pState = pState; 44 } 45 46 @Override 47 public boolean lockResources(PresentableState pState) { 48 return (getPhysicalWidth() != pState.getRenderWidth() || 49 getPhysicalHeight() != pState.getRenderHeight()); 50 } 51 52 public boolean prepare(Rectangle dirtyregion) { 53 if (!pState.isViewClosed()) { 54 /* 55 * RT-27374 56 * TODO: make sure the imgrep matches the Pixels.getNativeFormat() 57 * TODO: dirty region support 58 */ 59 int w = getPhysicalWidth(); 60 int h = getPhysicalHeight(); 61 pixels = pixelSource.getUnusedPixels(w, h, 1.0f); 62 IntBuffer pixBuf = (IntBuffer) pixels.getPixels(); 63 IntBuffer buf = getSurface().getDataIntBuffer(); 64 assert buf.hasArray(); 65 System.arraycopy(buf.array(), 0, pixBuf.array(), 0, w*h); 66 return true; 67 } else { 68 return false; 69 } 70 } 71 72 public boolean present() { 73 pixelSource.enqueuePixels(pixels); 74 pState.uploadPixels(pixelSource); 75 return true; 76 } 77 78 public float getPixelScaleFactor() { 79 return pState.getRenderScale(); 80 } 81 82 public int getContentWidth() { 83 return pState.getOutputWidth(); 84 } 85 86 public int getContentHeight() { 87 return pState.getOutputHeight(); 88 } 89 90 @Override public boolean isMSAA() { 91 return super.isMSAA(); 92 } 93 } | 41 public SWPresentable(PresentableState pState, SWResourceFactory factory) { 42 super(factory, pState.getRenderWidth(), pState.getRenderHeight()); 43 this.pState = pState; 44 } 45 46 @Override 47 public boolean lockResources(PresentableState pState) { 48 return (getPhysicalWidth() != pState.getRenderWidth() || 49 getPhysicalHeight() != pState.getRenderHeight()); 50 } 51 52 public boolean prepare(Rectangle dirtyregion) { 53 if (!pState.isViewClosed()) { 54 /* 55 * RT-27374 56 * TODO: make sure the imgrep matches the Pixels.getNativeFormat() 57 * TODO: dirty region support 58 */ 59 int w = getPhysicalWidth(); 60 int h = getPhysicalHeight(); 61 pixels = pixelSource.getUnusedPixels(w, h, 1.0f, 1.0f); 62 IntBuffer pixBuf = (IntBuffer) pixels.getPixels(); 63 IntBuffer buf = getSurface().getDataIntBuffer(); 64 assert buf.hasArray(); 65 System.arraycopy(buf.array(), 0, pixBuf.array(), 0, w*h); 66 return true; 67 } else { 68 return false; 69 } 70 } 71 72 public boolean present() { 73 pixelSource.enqueuePixels(pixels); 74 pState.uploadPixels(pixelSource); 75 return true; 76 } 77 78 @Override 79 public float getPixelScaleFactorX() { 80 return pState.getRenderScaleX(); 81 } 82 83 @Override 84 public float getPixelScaleFactorY() { 85 return pState.getRenderScaleY(); 86 } 87 88 public int getContentWidth() { 89 return pState.getOutputWidth(); 90 } 91 92 public int getContentHeight() { 93 return pState.getOutputHeight(); 94 } 95 96 @Override public boolean isMSAA() { 97 return super.isMSAA(); 98 } 99 } |